Binary, hex and friends: converting between number bases by hand
Computers store everything as binary (1s and 0s), humans read decimal, and programmers reach for hexadecimal because it packs four binary digits into one symbol. This tool converts a number between decimal (base 10), binary (base 2), octal (base 8) and hexadecimal (base 16) as you type — in either direction. Below is how the bases work and how to do the same conversions by hand when you don't have the tool.
Converting by hand: the place-value method
Every base works the same way: each digit has a place value equal to a power of the base. Take 42 in decimal — the 4 is in the "tens" place (101) and the 2 in the "ones" place (100).
Decimal to binary: divide repeatedly by 2, keeping the remainders. 42 ÷ 2 = 21 r0, 21 ÷ 2 = 10 r1, 10 ÷ 2 = 5 r0, 5 ÷ 2 = 2 r1, 2 ÷ 2 = 1 r0, 1 ÷ 2 = 0 r1. Reading the remainders bottom-up gives 101010 (32 + 8 + 2 = 42). That's exactly what the tool returns for "42 to binary".
Hex to decimal: multiply each digit by 16position. The hex value 2F is (2 × 16) + (F = 15) = 47. Octal works the same way with powers of 8 — octal 377 is (3 × 64) + (7 × 8) + 7 = 255.
The four systems at a glance
- Decimal (base 10): ten digits 0–9, the everyday counting system.
- Binary (base 2): the digits 0 and 1 — the on/off states of transistors that drive all of computing.
- Octal (base 8): digits 0–7. Historically used in early mainframes and still seen in Unix file permissions.
- Hexadecimal (base 16): digits 0–9 plus letters A–F (A = 10, F = 15). Compresses four bits into one character, so one byte (8 bits) is exactly two hex digits.
Quick reference matrix
| Decimal (base 10) | Binary (base 2) | Octal (base 8) | Hexadecimal (base 16) |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 5 | 0101 | 5 | 5 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 255 | 11111111 | 377 | FF |
The last row is the useful one: 255 is the largest value in one byte, and in hex it is a tidy FF — which is why computer-colour and byte values so often end in "FF".
Where you actually meet these bases
- CSS colours:
#FF5733is hex — red FF (255), green 57 (87), blue 33 (51). - IPv4 addresses:
192.168.1.1is four decimal octets, each the decimal form of an 8-bit binary value. - Unix file permissions:
chmod 755uses octal — 7, 5 and 5 are the rwx bits as base-8 digits. - MAC addresses and memory:
3C:22:FB:...:are hex pairs, and debuggers show memory addresses in hex for the same compression reason.
Base-conversion questions that keep coming up
Why do programmers use hex instead of writing binary directly?
Because one hex digit equals exactly four bits, so a long binary string like "1111 1111 1111 1111" becomes "FFFF". It's more compact and much harder to misread — the same information in a fraction of the characters.
How do I read letters in a hex input?
In hexadecimal, A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15. The tool accepts both upper and lowercase letters when converting to or from base 16.
Why is octal still around if binary and hex exist?
Mostly legacy — early computers used word sizes divisible by 3 bits. It survives today mainly in Unix file permissions, where each digit encodes three rwx bits (7 = rwx, 5 = r-x, and so on).
Can the tool convert fractional or negative numbers?
No — like most base converters, it handles non-negative integers. Fractions between bases need a different representation (binary points, floating point) and are out of scope for a quick conversion tool.