Number systems

Computers & Binary

  • Why Computers Use Binary

    • Data processed using logic gates with two states (0 = off, 1 = on).

    • All data must be converted to binary for computers to process efficiently.

    • Examples:

    • Magnetic hard drives use polarity (N/S) to represent binary values.

    • Optical disks use physical properties (land/pit) to represent binary values.

Number Systems

  • Denary Number System

    • Base-10 system using digits 0-9.

    • Each digit represents a power of 10 (e.g., 3268 = 3x10^3 + 2x10^2 + 6x10^1 + 8x10^0).

  • Binary Number System

    • Base-2 system using digits 1 and 0.

    • Each digit represents a power of 2 (e.g., 1100 in binary = 1x2^3 + 1x2^2 = 12).

    • Increasing number representation by adding bits.

  • Hexadecimal Number System

    • Base-16 system using digits 0-9 and letters A-F (10 = A, 11 = B, …, 15 = F).

    • Each digit represents a power of 16.

    • In GCSE, work with up to 2-digit hexadecimal values.

    • Example: Hexadecimal digit can represent 4 bits.

Conversions

  • Denary to Binary Conversion

    • Write down binary place values, starting from the largest down to 1.

    • Example: Denary 45 to binary results in 101101.

  • Binary to Denary Conversion

    • Write binary digits under binary place values, then sum the values where there are 1's.

    • Example: Binary 1011 = (1x8) + (1x2) + (1x1) = 11.

  • Hexadecimal to Denary Conversion

    • Convert hexadecimal to binary (4-bit nibbles) then to denary.

    • Example: Hex B9 = Binary 10111001 = Denary 185.

  • Denary to Hexadecimal Conversion

    • Divide denary number by 16 to get whole number and remainder.

    • Example: Denary 163 = A3 in hexadecimal (10 remainder 3).

Uses of Hexadecimal

  • Why Use Hexadecimal

    • Fewer digits represent larger values compared to binary.

    • Easier for humans to read and less prone to error.

  • Examples of Use:

    • MAC addresses (e.g., AA:BB:CC:DD:EE:FF)

    • Color codes (e.g., #66FF33)

    • URL encoding (special characters represented in hexadecimal).

Binary Addition

  • Binary Addition Rules:

    • 0 + 0 = 0

    • 1 + 0 = 1

    • 1 + 1 = 10 (carry 1)

  • Example:

    • Add 1001 (9) + 0100 (4) = 1101 (13).

Binary Shifts

  • Logical Binary Shift: Moves bits left or right.

    • Left shift: Multiplies by 2.

    • Right shift: Divides by 2.

  • Examples:

    • Left shift 40 (binary 00101000) results in 80 (binary 01010000).

    • Right shift 40 results in 20.

Two's Complement

  • Representing Negative Numbers:

    • MSB indicates sign: 1 for negative, 0 for positive.

    • Example: To find two's complement of -1 in 8-bit binary:

    • Positive 1 = 00000001 → Invert to get 11111110 → Add 1 → 11111111 (two's complement of -1).

  • Representing -76:

    • Positive 76 = 01001100 → Invert → 10110011 → Add 1 → 10110100.