Integers and two's complement

Unsigned and signed integers on 8, 16 and 32 bits: representable range, sign and magnitude, one's complement, two's complement and sign extension.

  • 27 cards
  • 6 topics
  • Free

The outline, topic by topic

Each topic is weighted the way the exam weighs it.

  1. Concepts
  2. Questions
  3. Sort and link
  4. On the timeline
  5. The numbers
  6. Understand

A few cards from the deck

  • Unsigned integer: what is it?

    Show the answer

    An integer coded on n bits that only represents positive values or zero, from 0 to 2ⁿ − 1.

    On 8 bits: 0 to 255. All 256 patterns stand for non-negative values, and no negative value exists.

  • On 8 bits, what is the pattern of −5 in two's complement?

    • 1111 1011
    • 1111 1010
    • 1000 0101
    • 0000 0101
    Show the answer

    1111 1011

    5 = 0000 0101, flipped 1111 1010, plus 1: 1111 1011. 1111 1010 is one's complement, 1000 0101 is sign and magnitude, 0000 0101 is +5.

  • To get the negation of an integer in two's complement, … all its bits then ….

    Show the answer

    To get the negation of an integer in two's complement, flip all its bits then add 1.

    Flipping alone gives one's complement, which is off by 1: −1 would then be 1111 1110 instead of 1111 1111.

  • Two's complement: what is it?

    Show the answer

    A signed integer encoding in which the negation of a number is obtained by flipping all its bits then adding 1.

    −42 on 8 bits: 42 = 0010 1010, flipped 1101 0101, plus 1: 1101 0110. Advantage: adding signed integers uses the same circuit as unsigned ones.