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.
Binary (Base 2)
Digits: 0, 1
Used by computers. Each position is worth 2× the one to its right.
Hexadecimal (Base 16)
Digits: 0-9, A, B, C, D, E, F
Shorthand for binary. Each hex digit = 4 binary digits.
| A = 10 | B = 11 | C = 12 |
| D = 13 | E = 14 | F = 15 |
Key Terms
The leftmost bit - has the highest place value
The rightmost bit - has the lowest place value (1)
Binary to Denary Conversion
Method: Add Place Values
- Write out the binary place values (128, 64, 32, 16, 8, 4, 2, 1)
- Write the binary number underneath, aligning from the right
- Add up the place values where there is a 1
Example: Convert 10110101 to denary
Try It: Binary to Denary Converter
Denary to Binary Conversion
Method: Repeated Division by 2
- Divide the number by 2
- Write down the remainder (0 or 1)
- Repeat with the quotient until you reach 0
- Read the remainders from bottom to top
Example: Convert 156 to binary
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
| Denary | Binary | Hex | Denary | Binary | Hex | |
|---|---|---|---|---|---|---|
| 0 | 0000 | 0 | 8 | 1000 | 8 | |
| 1 | 0001 | 1 | 9 | 1001 | 9 | |
| 2 | 0010 | 2 | 10 | 1010 | A | |
| 3 | 0011 | 3 | 11 | 1011 | B | |
| 4 | 0100 | 4 | 12 | 1100 | C | |
| 5 | 0101 | 5 | 13 | 1101 | D | |
| 6 | 0110 | 6 | 14 | 1110 | E | |
| 7 | 0111 | 7 | 15 | 1111 | F |
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
Example: Add 01101011 + 00110101
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)
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:
= 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:
= 00001010 (10) → 20 ÷ 2 = 10 ✓
00010101 (21) shifted right by 1:
= 00001010 (10) → 21 ÷ 2 = 10 (LSB lost!)
Quick Reference
| Operation | Shift Direction | Effect | Formula |
|---|---|---|---|
| Left shift by 1 | ← | ×2 | n × 2¹ |
| Left shift by 2 | ←← | ×4 | n × 2² |
| Left shift by 3 | ←←← | ×8 | n × 2³ |
| Right shift by 1 | → | ÷2 | n ÷ 2¹ |
| Right shift by 2 | →→ | ÷4 | n ÷ 2² |
| Right shift by 3 | →→→ | ÷8 | n ÷ 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