Computer Number Systems

Number Representation in Computers

Decimal System vs. Binary System

  • Decimal System:
    • Uses base 10.
    • Columns represent powers of 10 (e.g., ones, tens, hundreds).
    • Ten possible digits (0-9) for each placeholder.
  • Binary System:
    • Used by computers.
    • Uses base 2.
    • Based on transistors, which can be either off (0) or on (1).
    • Columns represent powers of 2 (e.g., ones, twos, fours).

Place Values in Binary

  • Decimal system columns represent powers of 10: 100,101,10210^0, 10^1, 10^2, etc.
  • Binary system columns represent powers of 2: 20,21,222^0, 2^1, 2^2, etc.
  • Example:
    • 20=12^0 = 1 (ones column)
    • 21=22^1 = 2 (twos column)
    • 22=42^2 = 4 (fours column)
    • 23=82^3 = 8 (eights column)
    • 24=162^4 = 16 (sixteens column)
    • 25=322^5 = 32 (thirty-twos column)
    • 26=642^6 = 64 (sixty-fours column)
    • 27=1282^7 = 128 (one-hundred-twenty-eights column)

Converting Binary to Decimal

  • Multiply the digit in each binary column by its corresponding power of 2.
  • Add the results to get the decimal equivalent.
  • Example: Binary 000
    • (4×0)+(2×0)+(1×0)=0(4 \times 0) + (2 \times 0) + (1 \times 0) = 0
  • Example: Binary 001
    • (4×0)+(2×0)+(1×1)=1(4 \times 0) + (2 \times 0) + (1 \times 1) = 1
  • Example: Binary 010
    • (4×0)+(2×1)+(1×0)=2(4 \times 0) + (2 \times 1) + (1 \times 0) = 2
  • Example: Binary 011
    • (4×0)+(2×1)+(1×1)=3(4 \times 0) + (2 \times 1) + (1 \times 1) = 3
  • Example: Binary 100
    • (4×1)+(2×0)+(1×0)=4(4 \times 1) + (2 \times 0) + (1 \times 0) = 4
  • Example: Binary 101
    • (4×1)+(2×0)+(1×1)=5(4 \times 1) + (2 \times 0) + (1 \times 1) = 5
  • Example: Binary 110
    • (4×1)+(2×1)+(1×0)=6(4 \times 1) + (2 \times 1) + (1 \times 0) = 6
  • Example: Binary 111
    • (4×1)+(2×1)+(1×1)=7(4 \times 1) + (2 \times 1) + (1 \times 1) = 7

Adding More Bits

  • To count higher, add more bits (transistors).
  • Each bit doubles the counting capacity.
  • Example: Four bits
    • 1000 in binary represents 8 in decimal ( (8×1)+(4×0)+(2×0)+(1×0)=8(8 \times 1) + (4 \times 0) + (2 \times 0) + (1 \times 0) = 8 ).

Bytes

  • A byte is a unit of 8 bits.
  • More practical than using only a few bits.
  • A byte can represent numbers from 0 to 255.

Byte Representation Example

  • Eight bits (one byte): 00000000 (decimal 0)

Maximum Value in a Byte

  • With eight bits, the highest number you can count to is 255.
  • All bits set to one: 11111111
  • (128+64+32+16+8+4+2+1=255)(128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255)
  • Including zero, there are 256 total possibilities (0-255).

Significance of Powers of Two

  • Numbers like 255 and 256 are common in computer systems because they relate to the units of measure (bytes) that systems use.