Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assume that 151 and 214 are signed 8-bit decimal integers stored in two’s comple

ID: 3816340 • Letter: A

Question

Assume that 151 and 214 are signed 8-bit decimal integers stored in two’s complement format. Calculate 151 + 214 by adding the two’s complement numbers first and then writing the final result in decimal. Then explain why the final result is very different from 366 (151+214=366). Note that if a number requires more than 8 bits, you need to represent first the number correctly using as many bits as necessary, then keep only the 8 bits, and use the resulting number in the arithmetic operation.
Then,
Calculate 151- 214 by performing binary addition.


Please show all work! Thank you for the help

Explanation / Answer

a.) The first step is to convert from decimal to binary, Then take the 2’s complement and Add 1,

A

151

B

214

10010111

11010110

2’s complement

01101000

00101001

+ 1

01101001

00101010

Then A + B

A

01101001

+B

00101010

=

10010010

   151           0110 1001   (105)
+   214       +   0010 1010   (42)
   127           0111 1111

Since signed 8-bit integers range is -128~127, the result using saturating arithmetic is 127, not 365.

8bit two’s complement is limited to representing numbers between -128 and +127.

In saturating arithmetic, numbers larger than max representation are clamped at the max (127 in this case), those smaller than min are clamped at min (-128).

If 2 Two's Complement numbers are added, and they both have the same sign (both positive or both negative), then overflow occurs if and only if the result has the opposite sign. Overflow never occurs when adding operands with different signs.

Overflow occurs if :

Therefore there is an overflow while adding 151 and 214 because on adding two positive number we get negative number.

Similarly for 151 and -214 we get ,

b.) The first step is to convert from decimal to binary, Then take the 2’s complement and Add 1,

A

151

B

214

10010111

11010110

2’s complement

01101000

00101001

+ 1

01101001

00101010

Then A - B

A

01101001

-B

00101010

=

00111110

   151           0110 1001   (105)
-   214       -   0010 1010   (42)
   063           0011 1111

Since signed 8-bit integers range is -128~127, the result using saturating arithmetic is 63.

There is underflow .

A

151

B

214

10010111

11010110

2’s complement

01101000

00101001

+ 1

01101001

00101010

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote