CS102: Positional Number Systems

Decimal (power base 10)

  • The weight of each digit is determined by its relative position.

    • ex. 1(1000’s) + 1(100’s) + 1(10’s) + 1(1’s) = 1111


Binary (power base 2) (DISTINGUISHED BY 0b)

  • A binary digit (0 or 1), and the weight of each of its bits, depends on its relative position within the number.

    • Each place increase results in a growth by a magnitude of 2

    • ex. 1(2^7) + 1(2^6) + 1 (2^5) + 1(2^4) + 1 (2³) + 1 (2²) + 1 (2^1) + 1 (2^0) = 1111 1111

    • Distinguished by a “0b” before a binary series of digits

  • Binary uses 0 and 1 to represent “True” and “False” values

  • Groups of 8 bits are referred to as bytes

    • ex. 0b 1111 1111 is a byte reference

Hexadecimal (power base 16) (DISTINGUISHED BY 0x)

  • Since Hexadecimals have a base of 16, digits 1-9 are represented by 1-9, but digits 10-16 are represented by A-F.

    • A = 10, B = 11, C = 12, D = 13, E = 14, F = 15

    • ex. 6572 = 1(4096) + 9(256) + A(16) + C(1) = 19AC


Number System Comparison: