← Back to Topics

Number Systems

Binary, Denary, and Hexadecimal conversions

What You'll Learn

🔢

Number Bases

Denary (base 10), Binary (base 2), Hexadecimal (base 16)

🔄

Conversions

Convert between all three number systems

➕

Binary Addition

Add binary numbers and understand overflow

↔️

Binary Shifts

Shift bits left and right to multiply/divide

Understanding Number Bases

What is a Number Base?

A number base (or radix) tells us how many different digits are used in a number system and how place values work.

Denary (Base 10)

Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

The number system we use every day. Each position is worth 10× the one to its right.

10³1000s
10²100s
10¹10s
10⁰1s
Example: 247 = (2×100) + (4×10) + (7×1)

Binary (Base 2)

Digits: 0, 1

Used by computers. Each position is worth 2× the one to its right.

2⁷128
2⁶64
2⁵32
2⁴16
2³8
2²4
2¹2
2⁰1
Example: 11010 = 16 + 8 + 2 = 26

Hexadecimal (Base 16)

Digits: 0-9, A, B, C, D, E, F

Shorthand for binary. Each hex digit = 4 binary digits.

A = 10B = 11C = 12
D = 13E = 14F = 15
Example: 2F = (2×16) + (15×1) = 47

Key Terms

Most Significant Bit (MSB)

The leftmost bit - has the highest place value

10110101 ← MSB
Least Significant Bit (LSB)

The rightmost bit - has the lowest place value (1)

10110101 ← LSB

Binary to Denary Conversion

Method: Add Place Values

  1. Write out the binary place values (128, 64, 32, 16, 8, 4, 2, 1)
  2. Write the binary number underneath, aligning from the right
  3. Add up the place values where there is a 1

Example: Convert 10110101 to denary

1286432168421
10110101
= 128 + 32 + 16 + 4 + 1 = 181

Try It: Binary to Denary Converter

128 64 32 16 8 4 2 1
Binary: 00000000 = Denary: 0

Denary to Binary Conversion

Method: Repeated Division by 2

  1. Divide the number by 2
  2. Write down the remainder (0 or 1)
  3. Repeat with the quotient until you reach 0
  4. Read the remainders from bottom to top

Example: Convert 156 to binary

156 ÷ 2 = 78 remainder 0
78 ÷ 2 = 39 remainder 0
39 ÷ 2 = 19 remainder 1
19 ÷ 2 = 9 remainder 1
9 ÷ 2 = 4 remainder 1
4 ÷ 2 = 2 remainder 0
2 ÷ 2 = 1 remainder 0
1 ÷ 2 = 0 remainder 1
Read bottom to top: 10011100

Alternative: Subtraction Method

Start with the largest place value that fits, subtract it, and mark a 1. Repeat.

156: Does 128 fit? Yes → 1, 156-128=28

28: Does 64 fit? No → 0

28: Does 32 fit? No → 0

28: Does 16 fit? Yes → 1, 28-16=12

12: Does 8 fit? Yes → 1, 12-8=4

4: Does 4 fit? Yes → 1, 4-4=0

0: 2 and 1 → 0, 0

Result: 10011100

Hexadecimal Conversions

Hexadecimal Reference Table

DenaryBinaryHexDenaryBinaryHex
000000810008
100011910019
200102101010A
300113111011B
401004121100C
501015131101D
601106141110E
701117151111F

Binary ↔ Hexadecimal

Split binary into groups of 4 bits (from right), convert each group.

Binary to Hex: 10110101

Split: 1011 | 0101

Convert: B | 5 = B5

Hex to Binary: 3F

3 = 0011, F = 1111

Result: 00111111

Denary ↔ Hexadecimal

Divide by 16 for each digit, or convert via binary.

Denary to Hex: 200

200 ÷ 16 = 12 remainder 8

12 = C, 8 = 8 → C8

Hex to Denary: 5A

(5 × 16) + (10 × 1)

= 80 + 10 = 90

Binary Addition

Binary Addition Rules

0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 10 (0, carry 1)
1 + 1 + 1 = 11 (1, carry 1)

Example: Add 01101011 + 00110101

11111
01101011
+00110101
=10100000

Verify: 107 + 53 = 160 ✓

Overflow Errors

An overflow error occurs when the result of a calculation is too large to be stored in the available number of bits.

Example: 11111111 + 00000001 (255 + 1)

11111111
+00000001
=100000000

The 9th bit (shown in red) cannot be stored in 8 bits. The result appears as 00000000 (0) instead of 256. This is an overflow error.

8-bit range: 0 to 255 (00000000 to 11111111)

Any result above 255 causes overflow in 8 bits.

Binary Shifts

What is a Binary Shift?

A binary shift moves all the bits in a binary number left or right by a specified number of positions.

Left Shift (×2 per shift)

Move bits left, fill empty positions on right with 0s.

Effect: Multiplies by 2 for each position shifted.

00001010 (10) shifted left by 1:

←0 00010100

= 00010100 (20) → 10 × 2 = 20 ✓

00000101 (5) shifted left by 2:

= 00010100 (20) → 5 × 4 = 20 ✓

Right Shift (÷2 per shift)

Move bits right, fill empty positions on left with 0s.

Effect: Divides by 2 for each position (integer division).

00010100 (20) shifted right by 1:

0 00001010→

= 00001010 (10) → 20 ÷ 2 = 10 ✓

00010101 (21) shifted right by 1:

= 00001010 (10) → 21 ÷ 2 = 10 (LSB lost!)

Quick Reference

OperationShift DirectionEffectFormula
Left shift by 1←×2n × 2¹
Left shift by 2←←×4n × 2²
Left shift by 3←←←×8n × 2³
Right shift by 1→÷2n ÷ 2¹
Right shift by 2→→÷4n ÷ 2²
Right shift by 3→→→÷8n ÷ 2³

Important Notes

  • Left shift overflow: Bits shifted past the MSB are lost
  • Right shift: Bits shifted past the LSB are lost (rounds down)
  • Shifting is faster than multiplication/division in computer hardware

Quick Reference

Number Ranges (8-bit)

  • Denary: 0 to 255
  • Binary: 00000000 to 11111111
  • Hex: 00 to FF

Conversion Tips

  • Binary ↔ Hex: Group by 4 bits
  • Denary → Binary: Divide by 2
  • Binary → Denary: Add place values

Binary Addition

  • 1 + 1 = 10 (carry the 1)
  • 1 + 1 + 1 = 11 (carry the 1)
  • Result > 255 = overflow

Practice Activities