What is a number base
A number base (or positional system) defines how many distinct symbols are used to write numbers. In base 10 (decimal) there are ten digits, 0 to 9. In base 2 (binary) there are only two: 0 and 1. The value of each digit depends on its position: in 255, the 2 is worth 200 because it sits in the hundreds place. Changing base means writing the same value with a different digit alphabet.
How conversion works
The trick is to always go through an intermediate point: the raw numeric value. First the number is interpreted in its source base to get that value (with parseInt(number, base)), then it is rewritten in the target base (with value.toString(base)). That is why 255 decimal, FF hexadecimal and 11111111 binary are the same number: they share the value, only the representation changes.
The four key bases
The same decimal value 255 looks very different depending on the base. This table sums it up:
| Base | Name | Digits | 255 in decimal |
|---|---|---|---|
| 2 | Binary | 0 1 | 11111111 |
| 8 | Octal | 0-7 | 377 |
| 10 | Decimal | 0-9 | 255 |
| 16 | Hexadecimal | 0-9 A-F | FF |
| 36 | Base 36 | 0-9 A-Z | 73 |
- Binary (2): the machine's native language, only 0 and 1.
- Octal (8): groups bits in threes; classic in Unix permissions (chmod 755).
- Decimal (10): the one people use every day.
- Hexadecimal (16): compact; two digits = one byte. Colors, memory, hashes.
Why hexadecimal uses letters
Base 16 needs sixteen symbols, but we only have ten digits (0-9). They are completed with the letters A, B, C, D, E and F, worth 10, 11, 12, 13, 14 and 15. So a number like 2A means 2×16 + 10 = 42. Universal convention: always uppercase to avoid confusion, as we do in this tool.
Real-world uses by field
- Colors: the CSS
#FF5733is three bytes (red, green, blue) in hexadecimal. - Permissions:
chmod 755uses octal, where each digit is three permission bits. - Networking: subnet masks and MAC addresses are read in binary and hexadecimal.
- Low level: memory addresses, dumps and bit flags in hexadecimal.
- Hashes and IDs: MD5, SHA and many identifiers are shown in hexadecimal.
Arbitrary bases up to 36
Beyond the four classics, you can convert to any base from 2 to 36. Base 36 uses the ten digits and the twenty-six letters (0-9, A-Z), and is used to shorten identifiers: a long number in decimal takes far fewer characters in base 36. It is the ceiling supported by the JavaScript toString function.