How to Convert Between Binary, Decimal, Octal & Hex
Number systems differ by their base — how many unique digits they use before rolling over to the next position. Decimal (base 10) uses 0–9. Binary (base 2) uses only 0 and 1 and is the native language of computers. Hexadecimal (base 16) uses 0–9 then A–F and is widely used in colour codes, memory addresses, and debugging. Octal (base 8) uses 0–7 and appears in Unix file permissions.
Last updated: March 31, 2026
The Formula
Decimal to Binary: divide by 2, record remainders bottom-to-top Binary to Decimal: Σ(bit × 2^position) reading right to left from position 0 Decimal to Hex: divide by 16, record remainders (10=A, 11=B … 15=F) Hex to Decimal: Σ(digit × 16^position)
Variable Definitions
| Symbol | Name | Description |
|---|---|---|
| Base | Radix | The number of unique digits in the number system (2 for binary, 8 for octal, 10 for decimal, 16 for hex) |
| bit | Binary Digit | A single 0 or 1 — the smallest unit of information in computing |
Step-by-Step Example
Convert decimal 156 to binary and hexadecimal.
Given
Solution
- 1Divide by 2 repeatedly:
156÷2=78 r0 | 78÷2=39 r0 | 39÷2=19 r1 | 19÷2=9 r1 | 9÷2=4 r1 | 4÷2=2 r0 | 2÷2=1 r0 | 1÷2=0 r1 - 2Read remainders bottom to top:
Binary = 10011100 - 3Verify: 128+16+8+4 = 156:
10011100 → 128+0+0+16+8+4+0+0 = 156 ✓ - 4Divide 156 by 16:
156 ÷ 16 = 9 remainder 12 (12 = C) - 59 ÷ 16 = 0 remainder 9:
Hex digits bottom to top: 9C
156 in decimal = 10011100 in binary = 0x9C in hexadecimal.
Ready to calculate?
Use the free Binary / Hex Converter — instant results, no sign-up.
Common Mistakes to Avoid
Reading remainders in the wrong order — for decimal to binary, read remainders from bottom to top (last remainder is the most significant bit).
Forgetting hex letters — 10=A, 11=B, 12=C, 13=D, 14=E, 15=F. A remainder of 12 is written as C.
Mixing up the 0x prefix — 0x9C means hex, not decimal. The prefix is just a notation convention.
Wrong bit position weighting — binary positions from right are 2⁰=1, 2¹=2, 2²=4, 2³=8, 2⁴=16, etc.