How base conversion works
In a positional number system, each digit is multiplied by the base raised to the power of its position. To convert into decimal, add up those values. To convert out of decimal, divide repeatedly by the new base and collect the remainders.
Value = dₙ × bⁿ + … + d₁ × b¹ + d₀ × b⁰
Example: The decimal number 255 is 11111111 in binary (eight 1-bits: 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1), 377 in octal (3 × 64 + 7 × 8 + 7) and FF in hexadecimal (15 × 16 + 15).
Quick reference
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 2 | 10 | 2 | 2 |
| 5 | 101 | 5 | 5 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 32 | 100000 | 40 | 20 |
| 64 | 1000000 | 100 | 40 |
| 100 | 1100100 | 144 | 64 |
| 128 | 10000000 | 200 | 80 |
| 255 | 11111111 | 377 | FF |
| 256 | 100000000 | 400 | 100 |
| 1024 | 10000000000 | 2000 | 400 |
Prefixes 0b (binary), 0o (octal) and 0x (hex) are accepted and ignored. Underscores and spaces used as digit separators are removed.
Frequently asked questions
How do I convert decimal to binary?
Repeatedly divide by 2 and record the remainders; reading them from last to first gives the binary number. 13 ÷ 2 = 6 r1, 6 ÷ 2 = 3 r0, 3 ÷ 2 = 1 r1, 1 ÷ 2 = 0 r1 → 1101.
How do I convert hexadecimal to decimal?
Multiply each digit by 16 raised to its position (counting from 0 on the right) and add. 2F = 2 × 16 + 15 × 1 = 47. The letters A–F stand for 10–15.
Why do programmers use hexadecimal?
Each hex digit represents exactly four binary digits (bits), so one byte is always two hex digits. That makes long binary values like memory addresses and colors (#1F5EFF) much easier to read.
Can I convert very large numbers?
Yes. The converter uses arbitrary-precision integers, so numbers with hundreds of digits are converted exactly. Fractions (digits after a point) are not supported.