Two's Complement

The questions below are due on Sunday September 27, 2026; 11:59:00 PM.
 
You are not logged in.

Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.
Back to Exercises

2's Complement Binary Representation

2's Complement to decimal

What is the decimal equivalent of 6-bit 2's complement number 0b101111?

What is the decimal equivalent of 6-bit 2's complement number 0b010011?

Decimal to 2's complement

Write -3 as a 5-bit binary number using 2's complement representation: 0b

Write the number -2 in 8-bit 2's complement representation: 0b

Write the number 18 in 6-bit 2's complement representation: 0b

Width of 2's complement numbers

What is the smallest number of bits required to represent -10 in 2's complement representation?

What is the largest positive number that can be represented with 4-bit 2's complement representation? (Provide your answer in decimal):

What is the smallest number that can be represented with 5-bit 2's complement representation? (Provide your answer in decimal):

2's complement arithmetic

Negate the 4-bit 2's complement number 0b1001 to make it a positive 2's complement number: 0b

Negate the 5-bit 2's complement number 0b01110 to make it a negative 2's complement number: 0b

What is the 4-bit result of adding 0b0111 to 0b0001? 0b

What is the smallest number of bits needed to properly represent the result of subtracting 0b0010 - 0b0100?

What is the result of 0b11110 - 0b00111 in 5-bit 2's complement notation?

Bitwise Shifts

For many operations (OR, AND, NOT, XOR, Left shift), 2's complement behaves the same as unsigned binary. However, the key difference is how 2's complement handles right shifting. For this set of questions, we will focus on comparing an arithmetic versus logical right shift of 2's complement numbers. Note that for left shifts there is no difference between arithmetic and logical shifts.

Assume that your result is of equal width as your input.

What is the result of the logical right shift 0b11010011 >> 3 in 2's complement notation? 0b

What is the result of the logical right shift 0b11010011 >> 3 in decimal?

What is the result of the arithmetic right shift 0b11010011 >> 3 in 2's complement notation?

What is the result of the arithmetic right shift 0b11010011 >> 3 in decimal?

What is the result of the arithmetic right shift 0b01100110 >> 4 in 2's complement notation?

Logical 2's Complement Operators: Comparison (==, !=, <, <=, > >=)

Logical operators take two numbers and produce a 0 (to indicate false) or 1 (to indicate true) output.

What is the result of the following logical comparisons assuming the values are in 2's complement notation?

0b100001 > 0b011101 =

0b100111 + 0b011001 == 0b000000 =

0b01001 - 0b11110 <= 0b01101 =

0b00101 + 0b11101 >= 0b10111 + 0b01110 =

Back to Exercises