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) {...
(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
(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
Write the binary tree representation for the Binary Search for also 17 elements and give the...
Write the binary tree representation for the Binary Search for also 17 elements and give the worst-case
1a. Convert 67 (base 10) to 8-bit binary using signed magnitude. Show your work. 1b. Convert...
1a. Convert 67 (base 10) to 8-bit binary using signed magnitude. Show your work. 1b. Convert 69 (base 10) to 8-bit binary using one’s complement. Show your work 1c. Convert 70 (base 10) to 8-bit binary using two’s complement. Show your work. 1d. Convert - 67 (base 10) to 8-bit binary using signed magnitude. 1e. Convert - 67 (base 10) to 8-bit binary using ones compliment. Show your work. 1f. Convert - 67 (base 10) to 8-bit binary using 2s...
Write -127 as 8 bit signed binary number both using 2'complement and sign/magnitude notation.
Write -127 as 8 bit signed binary number both using 2'complement and sign/magnitude notation.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT