- #1
needhelp83
- 199
- 0
Perform the following operations, representing the decimal numbers in 8-bit two’s complement code. Analyze whether the operations produce arithmetic overflow. Explain how you have estimated the overflows.
20 – 5; 127 –126; 127 – 128; -20 – 111; -20 – (+111);
- 43 - 120; -127 – 2; - 126 – 2.
I am having a very difficult time trying to understand this overflow concept. Any guidance would be greatly appreciated
*20-5
0001 0100 (20)
1111 0100 (-5) 2's
1 0000 1011
No overflow
*127-126
0111 1111 (127)
1000 0010 (-126) 2's
1 0000 0001 No overflow
*127 - 128
0111 1111 (127)
1000 0000 (-128) 2's
1111 1111 No overflow or carryout
*-20-111
1110 1100 (-20) 2's
1001 0001 (-111) 2's
1 0111 1101 Overflow (adding two negatives gives a positive)
*-20 - (+111)
1110 1100 (-20) 2's
1001 0001 (-111) 2's
1 0111 1101 Overflow (adding two negatives gives a positive)
*-43-120
1101 0101 (-43) 2's
1000 1000 (-120) 2's
1 0101 1101 Overflow (Adding 2 negatives gives a positive)
*-127-2
1000 0001 (-127) 2's
1111 1110 (-2) 2's
1 0111 1111 (Overflow 2 negatives gives a positive)
*-126-2
1000 0010 (-126) 2's
1111 1110 (-2) 2's
1 1000 0000 (No overflow)
Am I doing this correctly?
20 – 5; 127 –126; 127 – 128; -20 – 111; -20 – (+111);
- 43 - 120; -127 – 2; - 126 – 2.
I am having a very difficult time trying to understand this overflow concept. Any guidance would be greatly appreciated
*20-5
0001 0100 (20)
1111 0100 (-5) 2's
1 0000 1011
No overflow
*127-126
0111 1111 (127)
1000 0010 (-126) 2's
1 0000 0001 No overflow
*127 - 128
0111 1111 (127)
1000 0000 (-128) 2's
1111 1111 No overflow or carryout
*-20-111
1110 1100 (-20) 2's
1001 0001 (-111) 2's
1 0111 1101 Overflow (adding two negatives gives a positive)
*-20 - (+111)
1110 1100 (-20) 2's
1001 0001 (-111) 2's
1 0111 1101 Overflow (adding two negatives gives a positive)
*-43-120
1101 0101 (-43) 2's
1000 1000 (-120) 2's
1 0101 1101 Overflow (Adding 2 negatives gives a positive)
*-127-2
1000 0001 (-127) 2's
1111 1110 (-2) 2's
1 0111 1111 (Overflow 2 negatives gives a positive)
*-126-2
1000 0010 (-126) 2's
1111 1110 (-2) 2's
1 1000 0000 (No overflow)
Am I doing this correctly?