Skip to main content
Logo image

Dive Into Systems: Exercises

Section 4.4 Signed Binary Integers

Checkpoint 4.4.1. Two’s Complement.

    Which statement about two’s complement representation is correct?
  • It’s a format for signed integers.
  • Correct!
  • It’s an alternative format to represent unsigned integers.
  • Incorrect.
  • It’s a format for unsigned values, including both integers and fractions.
  • Incorrect.
  • It’s a format for signed values, including both integers and fractions.
  • Incorrect.

Checkpoint 4.4.2. Two’s Complement.

    Which type of integers can be represented by two’s complement binary?
  • Non-negative
  • Incorrect.
  • Negative
  • Incorrect.
  • Both A and B
  • Correct!
  • Neither A nor B
  • Incorrect.

Checkpoint 4.4.3. Two’s Complement.

    C has a signed char data type that uses 8-bit two’s complement representation. What’s the range of values this data type can represent?
  • \(0\) to \(2^8 - 1\)
  • Incorrect.
  • \(0\) to \(2^8\)
  • Incorrect.
  • \(-2^7\) to \(2^7 - 1\)
  • Correct!
  • \(-2^8\) to \(2^8 - 1\)
  • Incorrect.

Checkpoint 4.4.4. Two’s Complement.

    Which of the following statements is true about negating a two’s complement binary number?
  • Flip each bit and add a 1.
  • Correct!
  • The process is different for a positive number vs. for a negative number.
  • Incorrect.
  • Simply place the negative sign (-) before the number to negate it.
  • Incorrect.
  • Flip the most significant bit.
  • Incorrect.

Checkpoint 4.4.5. Most Significant Bit.

    Given the following 4-bit two’s complement binary number, how much does the most significant bit contribute to its total value?]
    1011
  • -8
  • Correct!
  • 8
  • Incorrect.
  • 1
  • Incorrect.
  • -1
  • Incorrect.

Checkpoint 4.4.6. Binary to Decimal.

For the following 8-bit sequence, 01001000, what is the decimal value when:
Interpreted as an unsigned value:
Interpreted as a signed (two’s complement) value:
Hint.
Non-negative values have the same representation under unsigned binary vs. two’s complement of the same width (other than leading zeros).

Checkpoint 4.4.7. Two’s Complement.

Given the following pairs of 4-bit two’s complement numbers, which of the two values in each pair is larger?
1101 or 1010?
1000 or 0111?

Checkpoint 4.4.8. Binary to Decimal.

For the following 8-bit sequence, 10010001, what is the decimal value when:
Interpreted as an unsigned value:
Interpreted as a signed (two’s complement) value:
Hint.
The most significant bit is now 1. How does that impact the value of the sign?

Checkpoint 4.4.9. Two’s Complement vs. Unsigned Binary.

    Which of the following statements correctly complete the sentence below?
    Bit sequence 10101000 ________________.
  • represents a positive value in unsigned binary format.
  • Correct!
  • represents a negative value in unsigned binary format.
  • Incorrect.
  • represents a positive value in 8-bit two’s complement format.
  • Incorrect.
  • represents a negative value in 16-bit two’s complement format.
  • Incorrect.
  • represents a negative value in 8-bit two’s complement format.
  • Correct!

Checkpoint 4.4.10. Negating Two’s Complement.

In binary, what is the negation of this 8-bit two’s complement value: 0110111?

Checkpoint 4.4.11. Sign Extention.

Perform sign extension on the following 4-bit two’s complement numbers to turn them into their equivalent 8-bit two’s complement representation.
0b0010 becomes
0b1100 becomes

Checkpoint 4.4.12. Sign Extention.

Suppose in C, you had the following statements:
char x;
short y;
x = -46;
y = x;
What is the binary representation of x?
What is the binary representation of y?

Checkpoint 4.4.13. Extension Uses.