Binary & Hex

Test yourself on Binary & Hex with exam style questions, marked instantly.

Flashcards that come back just before you would forget them.

A revision plan that remembers what you know and shows what to do next.

See which topics you have nailed and which need another look.

Quiz yourself on Binary & HexGet your flashcardsBuild my revision planTrack my progress

The Three Languages

Imagine you need to count sheep. You could count in English (1, 2, 3... - this is denary/decimal, base 10). A computer counts in binary - only two words: "baa" or "silence" (0 or 1, base 2). But binary gets long fast: "101101010" for 362 sheep! So we use hexadecimal (base 16) as a shorthand - like abbreviations. It's not a different number, just a shorter way to write it. 16A in hex = 362 in denary = 101101010 in binary. Same sheep, three languages!

Binary Place Values and Conversion

The binary number 11001001 written under the place values 128, 64, 32, 16, 8, 4, 2 and 1, split into two groups of four bits. The first four bits, 1100, are 12, which is C in hexadecimal. The last four bits, 1001, are 9, which is 9 in hexadecimal.

Add the place values that have a 1 under them: 128 + 64 + 8 + 1 = 201. Each group of four bits is one hexadecimal digit, so 11001001 = C9. A group of four bits is called a nibble (OCR and Edexcel name it).

Deep Dive: Why Do We Need Different Number Systems?

The Right Tool for the Right Job

Denary (Base 10): Humans use this naturally because we have 10 fingers. Uses digits 0-9.

Binary (Base 2): Computers use this because transistors have two states: ON (1) or OFF (0). Everything in a computer is ultimately binary - text, images, videos, programs. It's the computer's native language.

Hexadecimal (Base 16): Programmers use this as a compact shorthand for binary. Instead of writing "11111111", you write "FF". Much easier to read and less prone to errors. Uses digits 0-9 and letters A-F.

Number Systems Comparison

System Base Digits Used Used For
Denary (Decimal) Base 10 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Human counting, everyday numbers
Binary Base 2 0, 1 Computer storage, processing, machine code
Hexadecimal (Hex) Base 16 0-9, A, B, C, D, E, F Memory addresses, colors (RGB), MAC addresses, error codes

Hexadecimal Digit Values:

  Hex:    0  1  2  3  4  5  6  7  8  9  A   B   C   D   E   F
  Denary: 0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15
  

Binary: The Computer's Language

Understanding Place Values in Binary:

Just like denary has place values (ones, tens, hundreds), binary has place values based on powers of 2:

  Bit Position:  7      6     5    4    3   2   1   0
  Place Value:   128    64    32   16   8   4   2   1
  
  Example: 10110101
           1×128 + 0×64 + 1×32 + 1×16 + 0×8 + 1×4 + 0×2 + 1×1
           = 128 + 32 + 16 + 4 + 1 = 181 (denary)
  

Key Concepts:

  • Bit: A single binary digit (0 or 1)
  • 8-bit binary: Can represent 0-255 (28 = 256 values)
  • 16-bit binary: Can represent 0-65,535 (216 = 65,536 values)
  • Most Significant Bit (MSB): Leftmost bit (highest value)
  • Least Significant Bit (LSB): Rightmost bit (lowest value)

Denary to Binary Conversion

Method 1: Place Value Method (Easiest for Exams)

Write out the place values, then work left to right deciding if each place value fits.

Example: Convert 156 to binary

  Place values:  128   64   32   16   8   4   2   1
  Number: 156
  
  128 fits? YES → 1 (156 - 128 = 28 remaining)
   64 fits in 28? NO → 0
   32 fits in 28? NO → 0
   16 fits in 28? YES → 1 (28 - 16 = 12 remaining)
    8 fits in 12? YES → 1 (12 - 8 = 4 remaining)
    4 fits in 4? YES → 1 (4 - 4 = 0 remaining)
    2 fits in 0? NO → 0
    1 fits in 0? NO → 0
  
  Answer: 10011100
  

Method 2: Division Method

Repeatedly divide by 2, recording remainders from bottom to top.

Example: Convert 45 to binary

  45 ÷ 2 = 22 remainder 1  ← LSB (rightmost)
  22 ÷ 2 = 11 remainder 0
  11 ÷ 2 = 5  remainder 1
   5 ÷ 2 = 2  remainder 1
   2 ÷ 2 = 1  remainder 0
   1 ÷ 2 = 0  remainder 1  ← MSB (leftmost)
  
  Read remainders from bottom to top: 101101
  

Binary to Denary Conversion

Method: Add up place values where there's a 1

Example 1: Convert 11010110 to denary

  Place values: 128  64  32  16   8   4   2   1
  Binary:         1   1   0   1   0   1   1   0
  
  Add where there's a 1:
  128 + 64 + 16 + 4 + 2 = 214 (denary)
  

Example 2: Convert 10101 to denary

  Place values: 16   8   4   2   1
  Binary:        1   0   1   0   1
  
  16 + 4 + 1 = 21 (denary)
  

Hexadecimal: The Programmer's Shorthand

Why Hexadecimal is Used:

  • Compact: 1 hex digit = 4 binary bits. "FF" = "11111111" (much shorter!)
  • Human-readable: Easier to spot patterns and errors than long binary strings
  • Memory addresses: 0x7FFF is easier than 0111111111111111
  • Colors: #FF5733 (red=FF, green=57, blue=33)
  • MAC addresses: A4:5E:60:E2:7B:3C

Hex Notation:

  • Prefix with "0x" or "#" to indicate hex: 0xAF, #FF5733
  • Sometimes subscript: 2F16

Denary to Hexadecimal Conversion

Method: Repeated Division by 16

Example: Convert 195 to hexadecimal

  195 ÷ 16 = 12 remainder 3
   12 ÷ 16 = 0  remainder 12 (C in hex)
  
  Read from bottom to top: C3
  Answer: 195 (denary) = C3 (hex)
  
  Check: (12 × 16) + 3 = 192 + 3 = 195 ✓
  

Example 2: Convert 255 to hexadecimal

  255 ÷ 16 = 15 remainder 15
   15 ÷ 16 = 0  remainder 15
  
  15 in hex = F, so: FF
  Answer: 255 (denary) = FF (hex)
  

Hexadecimal to Denary Conversion

Method: Multiply place values (161, 160)

Example 1: Convert 3F to denary

  Place values:  16¹   16⁰
                 16    1
  Hex:           3     F
  
  3F = (3 × 16) + (15 × 1)
     = 48 + 15
     = 63 (denary)
  

Example 2: Convert 2A5 to denary

  Place values:  16²   16¹   16⁰
                 256   16    1
  Hex:           2     A     5
  
  2A5 = (2 × 256) + (10 × 16) + (5 × 1)
      = 512 + 160 + 5
      = 677 (denary)
  

Binary ↔ Hexadecimal: The Easy Shortcut

The 4-Bit Rule: 1 hex digit = exactly 4 binary bits

Conversion Table:

  Hex    Binary    Denary  |  Hex    Binary    Denary
   0     0000        0     |   8     1000        8
   1     0001        1     |   9     1001        9
   2     0010        2     |   A     1010       10
   3     0011        3     |   B     1011       11
   4     0100        4     |   C     1100       12
   5     0101        5     |   D     1101       13
   6     0110        6     |   E     1110       14
   7     0111        7     |   F     1111       15
  

Binary to Hex: Group by 4 bits

  Example: Convert 11010110 to hex
  
  Step 1: Group into 4s from right: 1101 0110
  Step 2: Convert each group:
          1101 = D (13)
          0110 = 6
  
  Answer: D6
  

Hex to Binary: Expand each digit to 4 bits

  Example: Convert 3A to binary
  
  Step 1: Convert each hex digit to 4 bits:
          3 = 0011
          A = 1010
  
  Step 2: Combine: 00111010
  

Real-World Application: RGB Colors

Web Color Codes: #FF5733

This hex code defines a color using Red, Green, Blue values:

  • FF = 255 red (maximum)
  • 57 = 87 green (medium)
  • 33 = 51 blue (low)

Result: A bright orange-red color. Each color channel is 0-255 (00-FF in hex), giving 16.7 million possible colors (256 × 256 × 256).

Why hex? "#FF5733" is much shorter and cleaner than "rgb(255, 87, 51)" and maps perfectly to binary (2 hex digits = 1 byte = one color channel).

Exam Tips - Binary & Hexadecimal

Most common exam questions:

  • "Convert X to binary" → Use place value method, show working
  • "Convert binary to denary" → Add up place values where bit = 1
  • "Why use hexadecimal?" → Compact/shorter than binary, easier for humans to read
  • "Convert hex to binary" → Expand each hex digit to 4 bits
  • "What is a bit?" → Single binary digit (0 or 1)

Key facts to memorize:

  • Binary place values: 128, 64, 32, 16, 8, 4, 2, 1
  • Hex letters: A=10, B=11, C=12, D=13, E=14, F=15
  • 1 hex digit = 4 binary bits (FF = 11111111)
  • 8-bit binary range: 0-255 (00-FF in hex)

Common mistakes to avoid:

  • Forgetting to show working - ALWAYS show place values!
  • Reading remainders wrong direction in division method
  • Mixing up hex letters (remember: A=10, F=15)
  • Not padding to 4 bits when converting hex to binary (3 must be 0011, not 11)
  • Saying "hexadecimal is faster" - NO! It's just a shorthand notation

Conversion strategy:

  1. Binary → Denary: Fastest method - add place values where bit = 1
  2. Denary → Binary: Use place value method (easier to show working than division)
  3. Hex ↔ Binary: Use 4-bit groups (fastest method!)
  4. Hex ↔ Denary: Convert via binary (hex→binary→denary) OR use multiplication/division by 16

Quick Reference - Number Systems

Conversion Cheat Sheet:

Denary Binary (8-bit) Hexadecimal
00000000000
10000010100A
160001000010
31000111111F
1000110010064
1281000000080
20011001000C8
25511111111FF

Common Uses in Computing:

  • Binary: All computer storage and processing (machine code, RAM, files)
  • Hex: Memory addresses (0x1A2F), colors (#FF5733), MAC addresses, error codes, assembly language
  • Denary: User interfaces, calculations we see on screen

Make this stick

Signing in gives access to all PrepWise features.

PrepWise is a trading name of A3M Quality Solutions Limited, registered in England and Wales, company number 14959172. Registered office: 202 Stroud Road, Gloucester, GL1 5LA. ICO registration ZC267069.