Positional number systems
In base \(b\), a number with digits \(d_i\) (each \(0 \le d_i < b\)) has the value
Each place is worth \(b\) times the place to its right. Base 10 uses digits 0–9; base 2 uses 0 and 1; base 16 uses 0–9 and A–F (A = 10 … F = 15); base 36 uses all of 0–9 and A–Z.
Step 1 – to decimal
Multiply each digit by its place value and add:
Step 2 – from decimal to base b
Whole part: divide by \(b\) repeatedly; the remainders, read from the last to the first, are the digits.
Fractional part: multiply by \(b\) repeatedly; the whole parts, read from the first to the last, are the digits.
Worked example
Example
Convert 255.625₁₀ to binary.
| Division | Quotient | Remainder |
|---|---|---|
| 255 ÷ 2 | 127 | 1 |
| 127 ÷ 2 | 63 | 1 |
| 63 ÷ 2 | 31 | 1 |
| 31 ÷ 2 | 15 | 1 |
| 15 ÷ 2 | 7 | 1 |
| 7 ÷ 2 | 3 | 1 |
| 3 ÷ 2 | 1 | 1 |
| 1 ÷ 2 | 0 | 1 |
Whole part: 11111111. Fraction: 0.625 × 2 = 1.25 → 0.25 × 2 = 0.5 → 0.5 × 2 = 1.0 → .101.
Result: \(255.625_{10} = 11111111.101_2 = 377.5_8 = \mathrm{FF.A}_{16}\).
Shortcuts between 2, 8 and 16
Because \(8 = 2^3\) and \(16 = 2^4\), each octal digit is exactly three bits and each hexadecimal digit exactly four bits. Group the bits from the point outwards:
Where bases are used
- Binary – how computers store numbers and logic levels.
- Hexadecimal – memory addresses, colour codes (#1B3A6B), byte values.
- Octal – Unix file permissions (chmod 755).
- Base 12 and 60 – dozens, hours and minutes, angles.
- Base 36 – short IDs and URL codes using all letters and digits.
FAQ
Why does 0.1 not convert exactly to binary?
A fraction terminates in base b only if its denominator has no prime factors other than those of b. 1/10 has the factor 5, which 2 lacks, so its binary form repeats forever.
How large can the numbers be?
Whole parts are converted with exact big-integer arithmetic, so there is no practical size limit. Fractional parts are given to 20 digits.
Can I type lower-case hex?
Yes. ff, Ff and FF are the same number.
What is the largest base?
Base 36, because there are 10 digits and 26 letters to write the digit values 0–35.
