Question

In: Computer Science

(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)

Solutions

Expert Solution

a)
70
Since this is a positive number. we can directly convert this into binary
Divide 70 successively by 2 until the quotient is 0
   > 70/2 = 35, remainder is 0
   > 35/2 = 17, remainder is 1
   > 17/2 = 8, remainder is 1
   > 8/2 = 4, remainder is 0
   > 4/2 = 2, remainder is 0
   > 2/2 = 1, remainder is 0
   > 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 1000110
So, 70 of decimal is 1000110 in binary
so, 70 in 2's complement binary is 01000110

-26
This is negative. so, follow these steps to convert this into a 2's complement binary
Step 1:
Divide 26 successively by 2 until the quotient is 0
   > 26/2 = 13, remainder is 0
   > 13/2 = 6, remainder is 1
   > 6/2 = 3, remainder is 0
   > 3/2 = 1, remainder is 1
   > 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 11010
So, 26 of decimal is 11010 in binary
So, 26 in normal binary is 00011010
Step 2: flip all the bits. Flip all 0's to 1 and all 1's to 0.
   00011010 is flipped to 11100101
Step 3:. Add 1 to above result
11100101 + 1 = 11100110
so, -26 in 2's complement binary is 11100110

b)
Adding 01000110 and 11100110 in binary
    01000110
    11100110
-------------
 (1)00101100
-------------
Sum produces a carry of 1. We can ignore that carry.
So, sum of these numbers in binary is 00101100

Verification:
---------------
sum = 00101100
since left most bit is 0, this number is positive
so, we can directly convert this into a decimal value
Converting 101100 to decimal
101100
=> 1x2^5+0x2^4+1x2^3+1x2^2+0x2^1+0x2^0
=> 1x32+0x16+1x8+1x4+0x2+0x1
=> 32+0+8+4+0+0
=> 44
Answer: 44
This is correct since we can verify that 70+-26 = 44
So, there was no overflow.

c)
Number: -70
Let's convert this to two's complement binary
-70
This is negative. so, follow these steps to convert this into a 2's complement binary
Step 1:
Divide 70 successively by 2 until the quotient is 0
   > 70/2 = 35, remainder is 0
   > 35/2 = 17, remainder is 1
   > 17/2 = 8, remainder is 1
   > 8/2 = 4, remainder is 0
   > 4/2 = 2, remainder is 0
   > 2/2 = 1, remainder is 0
   > 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 1000110
So, 70 of decimal is 1000110 in binary
So, 70 in normal binary is 01000110
Step 2: flip all the bits. Flip all 0's to 1 and all 1's to 0.
   01000110 is flipped to 10111001
Step 3:. Add 1 to above result
10111001 + 1 = 10111010
so, -70 in 2's complement binary is 10111010

Number: 26
Let's convert this to two's complement binary
26
Since this is a positive number. we can directly convert this into binary
Divide 26 successively by 2 until the quotient is 0
   > 26/2 = 13, remainder is 0
   > 13/2 = 6, remainder is 1
   > 6/2 = 3, remainder is 0
   > 3/2 = 1, remainder is 1
   > 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 11010
So, 26 of decimal is 11010 in binary
so, 26 in 2's complement binary is 00011010

Adding 10111010 and 00011010 in binary
    10111010
    00011010
-------------
 (0)11010100
-------------
Sum does not produces a carry
So, sum of these numbers in binary is 11010100

Verification:
---------------
sum = 11010100
since left most bit is 1, this number is negative number.
so, follow these steps below to convert this into a decimal value.
I. first flip all the bits. Flip all 0's to 1 and all 1's to 0.
   11010100 is flipped to 00101011
II. Add 1 to above result
00101011 + 1 = 00101100
III. Now convert this result to decimal value
Converting 101100 to decimal
101100
=> 1x2^5+0x2^4+1x2^3+1x2^2+0x2^1+0x2^0
=> 1x32+0x16+1x8+1x4+0x2+0x1
=> 32+0+8+4+0+0
=> 44
Answer: -44
This is correct since we can verify that -70+26 = -44
So, there was no overflow.

d)
Number: 70
Let's convert this to two's complement binary
70
Since this is a positive number. we can directly convert this into binary
Divide 70 successively by 2 until the quotient is 0
   > 70/2 = 35, remainder is 0
   > 35/2 = 17, remainder is 1
   > 17/2 = 8, remainder is 1
   > 8/2 = 4, remainder is 0
   > 4/2 = 2, remainder is 0
   > 2/2 = 1, remainder is 0
   > 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 1000110
So, 70 of decimal is 1000110 in binary
so, 70 in 2's complement binary is 01000110

Number: 26
Let's convert this to two's complement binary
26
Since this is a positive number. we can directly convert this into binary
Divide 26 successively by 2 until the quotient is 0
   > 26/2 = 13, remainder is 0
   > 13/2 = 6, remainder is 1
   > 6/2 = 3, remainder is 0
   > 3/2 = 1, remainder is 1
   > 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 11010
So, 26 of decimal is 11010 in binary
so, 26 in 2's complement binary is 00011010

Adding 01000110 and 00011010 in binary
    01000110
    00011010
-------------
 (0)01100000
-------------
Sum does not produces a carry
So, sum of these numbers in binary is 01100000

Verification:
---------------
sum = 01100000
since left most bit is 0, this number is positive
so, we can directly convert this into a decimal value
Converting 1100000 to decimal
1100000
=> 1x2^6+1x2^5+0x2^4+0x2^3+0x2^2+0x2^1+0x2^0
=> 1x64+1x32+0x16+0x8+0x4+0x2+0x1
=> 64+32+0+0+0+0+0
=> 96
Answer: 96
This is correct since we can verify that 70+26 = 96
So, there was no overflow.

Related Solutions

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.
(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 the following decimal numbers to 16-bit 2’s complement binary. Display your result in hexadecimal. a.3030...
Convert the following decimal numbers to 16-bit 2’s complement binary. Display your result in hexadecimal. a.3030 b.404 c.5050 d.-5050 e.-20000 Show work with steps
Add or subtract the following 2’s complement form signed numbers, then convert the entire problem to...
Add or subtract the following 2’s complement form signed numbers, then convert the entire problem to decimal and confirm: 110110 + 111000 001100 – 011100
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) {...
The standard method of representing negative numbers in the binary system is with 2's complement notation....
The standard method of representing negative numbers in the binary system is with 2's complement notation. What are the advantages and disadvantages of using this method to represent negative numbers?
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?
Design a 9’s complement of a Binary Coded Decimal
Design a 9’s complement of a Binary Coded Decimal
Write a program to convert the input numbers to another number system. 1. Decimal to Binary...
Write a program to convert the input numbers to another number system. 1. Decimal to Binary 2. Binary to Decimal 3. Hexadecimal to Decimal 4. Decimal to Hexadecimal 5. Binary to Hexadecimal 6. Hexadecimal to Binary The user will type in the input number as following: Binary number : up to 8 bits Hexadecimal number: up to 2 bytes Decimal number: Less than 256 As a result, print out the output after the conversion with their input numbers. The program...
Convert these numbers from Decimal to Binary 111: 66: 252 11 20 Convert these numbers from...
Convert these numbers from Decimal to Binary 111: 66: 252 11 20 Convert these numbers from Binary to Decimal 00110110 11111000 00000111 10101010 What is the Default Subnet mask of Class A IPV4 What is the Default Subnet mask of Class B IPV4 What is the Default Subnet mask of Class C IPV4 What is the CIDR notation or / short handwriting of Subnet masks: Class A: /?. Explain the reason Class B: /? Explain the reason Class C: /?...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT