Bit numbering

  • bit (b) is the smallest unit of data in a computer

  • Byte (B) is 8 bits

    • Nibble is 4 bits
  • Word is the natural unit of data used by a particular processor design, (in our course, it is 32 bits=4 bytes)

    • Halfword is 16 bits
  • Least significant bit (LSB) is the rightmost bit

  • Most significant bit (MSB) is the leftmost bit

Signed numbers

Sign–magnitude

  • if is a positive number, then is the negative of that number
  • the most significant bit is the sign bit
  • the range is to

One’s complement

  • the range is to
  • the negative of a number is obtained by inverting all bits
    • example:

Two’s complement

  • the range is to
  • If is a positive number, then we can find its negative by:
    • invert (flip) each bit (One’s complement) and add 1 to the result:
      • example:
    • subtract from :
      • example:

signed binary numbers

4-bit

BinaryUnsignedTwo’s complementSign–magnitudeOne’s complement
00000000
00011111
00102222
00113333
01004444
01015555
01106666
01117777
10008-8-0-7
10019-7-1-6
101010-6-2-5
101111-5-3-4
110012-4-4-3
110113-3-5-2
111014-2-6-1
111115-1-7-0

8-bit

BinaryUnsignedTwo’s complementSign–magnitudeOne’s complement
000000000000
000000011111
01111110126126126126
01111111127127127127
10000000128-128-0-127
10000001129-127-1-126
11111110254-2-126-1
11111111255-1-127-0