Two's Complement Arithmetic

This section includes exercises on 2's complement arithmetic: negation, addition, and subtraction. Multiplication and division exercises are not included yet.

How to use an exercise:

Exercise 1. 8-bit 2's Complement: Negation

Negate a 2's complement number: given a number n in 2's complement, please provide (-n)'s 2's complement representation in the same number of bits.

Reference: a lecture on 2's complemet negation.

1. Generate a random 8-bit 2's Complement number:

2. Please negate this 2's complement number
and indicate whether overflow happened:
- (Enter result here)
Overflow?
3. Now check your answer:

-

4. Show the solution:

-

Exercise 2. 8-bit 2's Complement: Addition

Reference: lecture on 2's complement addition.

1. Generate two random numbers in 8-bit 2's Complement:

+

2. Please add them together and specify any carry/overflow: - (Enter result here. Should be 8 bits)
Carry out of MSB?
Overflow?        
3. Now check your answer:

-

4. Show the solution:

-

Exercise 3. 8-bit 2's Complement: Subtraction

Reference: lecture on 2's complement subtraction.

1. Generate two random numbers in 8-bit 2's Complement:

-

2. Please perform subtraction and specify any carry/overflow: - (Enter result here. Should be 8 bits)
Carry out of MSB?
Overflow?        
3. Now check your answer:

-

4. Show the solution:

-

 

© 2022 Bin Peng
Bug reports and comments are welcome: crystal dot peng at park dot edu

Last Update:
Created: August 24, 2020