General Math
Binary, Decimal, Hex, Octal: Complete Guide to Number Base Conversion
Learn how to convert between binary, decimal, hexadecimal, and octal number systems. Step-by-step method for computer science students and developers.
Different number bases exist because computers think in binary, humans prefer decimal, and programmers often use hex for brevity. Understanding conversions is essential for CS students and developers.
Why different bases?
| Base | Name | Used for |
|---|---|---|
| 2 | Binary | How computers store everything |
| 8 | Octal | Unix file permissions (chmod 755) |
| 10 | Decimal | Human counting |
| 16 | Hexadecimal | Memory addresses, colours (#FF5733) |
Decimal to binary (division method)
Repeatedly divide by 2 and collect remainders (bottom to top):
25 ÷ 2 = 12 remainder 1
12 ÷ 2 = 6 remainder 0
6 ÷ 2 = 3 remainder 0
3 ÷ 2 = 1 remainder 1
1 ÷ 2 = 0 remainder 1
25₁₀ = 11001₂ (read remainders bottom→top)
Binary to decimal (positional method)
Multiply each digit by its position value (powers of 2):
11001₂ = 1×2⁴ + 1×2³ + 0×2² + 0×2¹ + 1×2⁰
= 16 + 8 + 0 + 0 + 1 = 25₁₀
Hexadecimal
Hex uses 0–9 and A–F (A=10, B=11, C=12, D=13, E=14, F=15).
- Decimal 255 = FF in hex (15×16 + 15 = 255)
- Hex colour #FF5733 = Red:255, Green:87, Blue:51
Quick tip: Each hex digit = exactly 4 binary digits:
F = 1111, A = 1010, 3 = 0011
FA3₁₆ = 1111 1010 0011₂
Octal
Octal uses digits 0–7. Each octal digit = 3 binary digits.
Unix permissions: chmod 755
- 7 = 111 (read+write+execute)
- 5 = 101 (read+execute)
- 5 = 101 (read+execute)
General conversion method
To convert between any two bases, go through decimal as an intermediate:
- Source → Decimal (positional multiplication)
- Decimal → Target (repeated division)
Or for binary↔hex/octal, use the grouping shortcut (group binary digits by 4 for hex, by 3 for octal).
Common values to memorise
| Decimal | Binary | Hex | Octal |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 8 | 1000 | 8 | 10 |
| 10 | 1010 | A | 12 |
| 15 | 1111 | F | 17 |
| 16 | 10000 | 10 | 20 |
| 255 | 11111111 | FF | 377 |
Convert any number between bases with our Number Base Converter — shows all bases simultaneously with step-by-step working.
OurDailyCalc Team
OurDailyCalc — beautiful tools for everyday calculations.