Question

In: Computer Science

convert +38 and +17 to binary using the signed 2s complement representation and enough digits to...

convert +38 and +17 to binary using the signed 2s complement representation and enough digits to accomaodate the numbers. Then perform the binary equivalent of (-38) and +17

Solutions

Expert Solution

Calculating 38 in binary:
--------------------------
Write down the decimal number and continually divide by 2 to give a result and a remainder. The remainder is either a 1 or a 0.

38 /  2  result 19 remainder  0
19 /  2  result 9  remainder  1
9  /  2  result 4  remainder  1
4  /  2  result 2  remainder  0
2  /  2  result 1  remainder  0
1  /  2  result 0  remainder  1

Read the remainders from bottom to top.

( 38 )10 = ( 100110 )2

So, fill zeros to the front to make it 8 bit

( 38 )10 = ( 00100110 )2

Ones complement = Inverting all the bits in binary
                = 11011001
Twos complement = Ones complement + 1
                = 11011001 + 1
                = 11011010

So, -38 in binary is 11011010

=====================================

Calculating 17 in binary:
--------------------------
Write down the decimal number and continually divide by 2 to give a result and a remainder. The remainder is either a 1 or a 0.

17 /  2  result 8  remainder  1
8  /  2  result 4  remainder  0
4  /  2  result 2  remainder  0
2  /  2  result 1  remainder  0
1  /  2  result 0  remainder  1

Read the remainders from bottom to top.

( 17 )10 = ( 10001 )2

So, fill zeros to the front to make it 8 bit

( 17 )10 = ( 00010001 )2

So, 17 in binary is 00010001

=====================================

Calculating -38+17 =
-------------------------

  11011010
+ 00010001
------------
  11101011
------------

So, the result of -38+17 in binary is 11101011

we have to convert 11101011 back to decimal to make answer in decimal
As MSB is 1, this is in two's complement

Ones complement = Twos complement - 1
                = 11101011 - 1
                = 11101010
Binary = -Inverting all the bits in binary
       = -00010101
So, The decimal value of 00010101 is 21

So, 11101011 in decimal is -21

Final Answer in binary is 11101011
Final Answer in decimal is -21




Related Solutions

(16%) Convert decimal +47 and +38 to binary, using the signed-2’s-complement representation and enough digits to...
(16%) Convert decimal +47 and +38 to binary, using the signed-2’s-complement representation and enough digits to accommodate the numbers, Then, perform the binary equivalent of (+47)+(-38) and (-47)+(-38) using addition. Convert the answers back to decimal and verify that they are correct.
Convert decimal +47 and +31 to binary, using the signed-2’s-complement representation and enough digits to accommodate...
Convert decimal +47 and +31 to binary, using the signed-2’s-complement representation and enough digits to accommodate the numbers. Then perform the binary equivalent of (+31)+(-47), (-31)+(+47), and (-31)+(-47). Convert the answers back to decimal and verify that they are correct.
i need to convert decimal to twos complement binary and then add the binary digits but...
i need to convert decimal to twos complement binary and then add the binary digits but I am unable to do it. I am only allowed to use string, can anyone help me out please. i need the code urgently. #include #include #include #include using namespace std; string reverse(string s) { string x = ""; for (long i = s.length() - 1; i >= 0; i--) { x += s[i]; } return x; } string twosComplementStringsAddition(string A, string B) {...
Assuming signed two’s complement representation using m=8 bits, add the following numbers using binary addition AND...
Assuming signed two’s complement representation using m=8 bits, add the following numbers using binary addition AND determine the values of the N, Z, V and C flags in response to each calculation. (-128) + (+100) (+5) + (+7) (+5) + (-7) (-5) + (+7) (-5) + (-7) (+120) + (+100) (-120) + (-100) (6A)16+ (E2)16 (A7)16+ (35)16 (80)16+ (80)16
(a) Convert the decimal numbers, 70 and -26 to binary in the signed 2’s complement system....
(a) Convert the decimal numbers, 70 and -26 to binary in the signed 2’s complement system. Make sure there are enough digits in the results to be able to perform arithmetic operations with these two numbers. (b) Perform in the signed 2’s complement system, (+70) + (-26) (c) Perform in the signed 2’s complement system, (-70) - (-26) (d) Perform in the signed 2’s complement system, (+70) + (+26)
1.convert the following numbers from decimal to binary assuming seven-bit twe's complement binary representation: a)49 b)...
1.convert the following numbers from decimal to binary assuming seven-bit twe's complement binary representation: a)49 b) -27 c)0 d) -64 e) -1 f) -2 g) what is the range for this computer as written in binary and in decimal? 2.convert the following numbers from decimal to binary assuming nine-bit twe's complement binary representation: a)51 b) -29 c) -2 d)0 e) -256 f) -1 g ) what is the range for this computer as written in binary and in decimal?
Represent the following numbers in binary 8-bit representation using singed magnitude, one's complement, two's complement, and...
Represent the following numbers in binary 8-bit representation using singed magnitude, one's complement, two's complement, and excess-127 representations: a) 48 b) -35
Convert signed integer 0xACE9 to binary and decimal. Convert unsigned integer0xACE9 to binary and decimal.
Convert signed integer 0xACE9 to binary and decimal. Convert unsigned integer0xACE9 to binary and decimal.
(6 pts) Convert the data representation given below • Convert 10110111 unsigned binary representation, to decimal...
(6 pts) Convert the data representation given below • Convert 10110111 unsigned binary representation, to decimal representation. • Convert 01100000101110000001010111111000 the binary representation to a hexadecimal representation. • Convert 0xBAAADA55 hexadecimal representation, to a binary representation. 2. (8 pts) Complete the following arithmetic operations in two’s complement representation. What are the values of the carry flag and the overflow flag? (Assume a six-bit system) • 31 + 11 • 13 – 15 • (-2) x (-16) • (-15) ÷ 5
For m=4 bits, using the signed two’s complement representation, (neatly) construct a table consisting of all...
For m=4 bits, using the signed two’s complement representation, (neatly) construct a table consisting of all possible 4 bit sequences along with their base 10 values.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT