Convert between binary, octal, decimal and hexadecimal
Number base conversion translates values between different numeral systems — binary (base-2), octal (base-8), decimal (base-10), and hexadecimal (base-16). Computers operate in binary, but developers need different bases depending on context.
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 255 | 11111111 | 377 | FF |
255.0.0.0 = 11111111.00000000...)chmod 755 = rwxr-xr-x)#FF5733), byte stream debuggingCode prefixes: 0b (binary) · 0o (octal) · 0x (hexadecimal)
chmod 644 (read/write/execute bits)Each hex digit maps exactly to 4 binary bits (1 nibble), making hex-to-binary conversion trivial. 0xFF is 1111 1111 — far more compact than writing raw binary.
In modern development, rarely. Unix file permissions are the primary use case. You may also encounter octal in legacy C code and certain protocols (e.g., MIDI).
Memorize key anchors: 0xA=10, 0xF=15, 0x10=16, 0xFF=255, 0x100=256. Most conversions can be derived from these reference points.