Binary, Octal, Decimal and Hex Conversion Table
Binary, octal, decimal and hex side by side, from 0 to 65536.
No signup, no trackingComputers count in binary, memory addresses and colors are written in hexadecimal, and Unix file permissions are octal. Moving between those four bases is a daily chore rather than an interesting problem, which is exactly what a lookup table is for.
This page holds the tables worth bookmarking: the sixteen-row nibble chart that makes binary-to-hex conversion mechanical, a full listing from 0 to 32, powers of two up to 2^16, and the byte values that keep showing up in ASCII, subnet masks and UTF-8. Worked examples at the end show how to do each conversion by hand. Every value here was generated by a program, not typed from memory.
The 4-bit table: the only one worth memorising
Sixteen is a power of two, which is the whole reason hexadecimal exists. One hex digit encodes exactly four binary digits — a nibble — with no remainder and no carrying between groups. Learn these sixteen rows and every binary-to-hex conversion becomes a lookup rather than arithmetic.
| Decimal | Binary (4 bits) | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 3 | 0011 | 3 | 3 |
| 4 | 0100 | 4 | 4 |
| 5 | 0101 | 5 | 5 |
| 6 | 0110 | 6 | 6 |
| 7 | 0111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 9 | 1001 | 11 | 9 |
| 10 | 1010 | 12 | A |
| 11 | 1011 | 13 | B |
| 12 | 1100 | 14 | C |
| 13 | 1101 | 15 | D |
| 14 | 1110 | 16 | E |
| 15 | 1111 | 17 | F |
Conversion table from 0 to 32
Written without leading zeros, so you can see how many bits each value actually needs. Note where the digit count jumps: at 2, 4, 8, 16 and 32 — every power of two adds a bit.
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 2 | 10 | 2 | 2 |
| 3 | 11 | 3 | 3 |
| 4 | 100 | 4 | 4 |
| 5 | 101 | 5 | 5 |
| 6 | 110 | 6 | 6 |
| 7 | 111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 9 | 1001 | 11 | 9 |
| 10 | 1010 | 12 | A |
| 11 | 1011 | 13 | B |
| 12 | 1100 | 14 | C |
| 13 | 1101 | 15 | D |
| 14 | 1110 | 16 | E |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 17 | 10001 | 21 | 11 |
| 18 | 10010 | 22 | 12 |
| 19 | 10011 | 23 | 13 |
| 20 | 10100 | 24 | 14 |
| 21 | 10101 | 25 | 15 |
| 22 | 10110 | 26 | 16 |
| 23 | 10111 | 27 | 17 |
| 24 | 11000 | 30 | 18 |
| 25 | 11001 | 31 | 19 |
| 26 | 11010 | 32 | 1A |
| 27 | 11011 | 33 | 1B |
| 28 | 11100 | 34 | 1C |
| 29 | 11101 | 35 | 1D |
| 30 | 11110 | 36 | 1E |
| 31 | 11111 | 37 | 1F |
| 32 | 100000 | 40 | 20 |
Powers of two
These are the numbers that explain why buffers are 4096 bytes, why an unsigned byte stops at 255 and why a port number cannot exceed 65535. In binary a power of two is always a single 1 followed by zeros, and in hex it is always 1, 2, 4 or 8 followed by zeros.
| Power | Decimal | Binary | Hex |
|---|---|---|---|
| 2^0 | 1 | 1 | 1 |
| 2^1 | 2 | 10 | 2 |
| 2^2 | 4 | 100 | 4 |
| 2^3 | 8 | 1000 | 8 |
| 2^4 | 16 | 10000 | 10 |
| 2^5 | 32 | 100000 | 20 |
| 2^6 | 64 | 1000000 | 40 |
| 2^7 | 128 | 10000000 | 80 |
| 2^8 | 256 | 100000000 | 100 |
| 2^9 | 512 | 1000000000 | 200 |
| 2^10 | 1,024 | 10000000000 | 400 |
| 2^11 | 2,048 | 100000000000 | 800 |
| 2^12 | 4,096 | 1000000000000 | 1000 |
| 2^13 | 8,192 | 10000000000000 | 2000 |
| 2^14 | 16,384 | 100000000000000 | 4000 |
| 2^15 | 32,768 | 1000000000000000 | 8000 |
| 2^16 | 65,536 | 10000000000000000 | 10000 |
Common byte values
A byte holds 8 bits, so exactly 256 values, written as two hex digits. These are the ones you actually meet when reading a hex dump or debugging an encoding problem.
| Decimal | Binary (8 bits) | Hex | What it is |
|---|---|---|---|
| 0 | 00000000 | 00 | Null byte |
| 9 | 00001001 | 09 | Tab |
| 10 | 00001010 | 0A | Line feed (LF, Unix newline) |
| 13 | 00001101 | 0D | Carriage return (CR) |
| 27 | 00011011 | 1B | Escape — starts ANSI terminal codes |
| 32 | 00100000 | 20 | Space |
| 48 | 00110000 | 30 | Digit "0" |
| 57 | 00111001 | 39 | Digit "9" |
| 65 | 01000001 | 41 | Letter "A" |
| 90 | 01011010 | 5A | Letter "Z" |
| 97 | 01100001 | 61 | Letter "a" |
| 122 | 01111010 | 7A | Letter "z" |
| 127 | 01111111 | 7F | DEL — last 7-bit ASCII value |
| 128 | 10000000 | 80 | First byte outside ASCII; INT8 minimum in two’s complement |
| 160 | 10100000 | A0 | Non-breaking space in Latin-1 |
| 191 | 10111111 | BF | Upper bound of UTF-8 continuation bytes |
| 192 | 11000000 | C0 | Common subnet mask octet (/26) |
| 224 | 11100000 | E0 | Subnet mask octet (/27) |
| 240 | 11110000 | F0 | Subnet mask octet (/28); high nibble set |
| 254 | 11111110 | FE | Highest usable octet in many networks |
| 255 | 11111111 | FF | UINT8 maximum; all eight bits set |
How to convert by hand
Three procedures cover everything. Binary to decimal is addition, decimal to binary is repeated division, and binary to hex is pure grouping — the last one never requires arithmetic at all.
- Binary to decimal: label each bit with its power of two, right to left starting at 2^0, then add up the powers wherever the bit is 1.
- Decimal to binary: divide by 2 repeatedly, writing down each remainder, until the quotient reaches 0. Read the remainders bottom to top.
- Binary to hex: pad the left with zeros until the length is a multiple of 4, split into groups of four from the right, then replace each group using the nibble table above.
- Hex to binary: replace each hex digit with its four-bit pattern and concatenate. No carrying, no arithmetic.
- Binary to octal: identical to hex but with groups of three bits, since 8 is 2^3.
Worked examples
Binary to decimal: 10011100
2^7 (128) + 2^4 (16) + 2^3 (8) + 2^2 (4) = 156Decimal to binary: 156
156 ÷ 2 = 78 remainder 0
78 ÷ 2 = 39 remainder 0
39 ÷ 2 = 19 remainder 1
19 ÷ 2 = 9 remainder 1
9 ÷ 2 = 4 remainder 1
4 ÷ 2 = 2 remainder 0
2 ÷ 2 = 1 remainder 0
1 ÷ 2 = 0 remainder 1
Read the remainders bottom to top: 10011100Binary to hex: 11001010
1100 1010 → C A → 0xCAHex to decimal: 0x2F
2 × 16 + 15 = 47
Binary to octal: 10011100
010 011 100 → 2 3 4 → 0o234Gotchas
- Leading zeros carry no numeric value but do carry width. 00001010 and 1010 are both decimal 10, yet the first says "one byte" and the second says "four bits" — and width is exactly what matters in a protocol or a struct.
- Prefixes disambiguate the base: 0b for binary, 0o for octal, 0x for hex. A bare 10 is ambiguous, and 0755 in C-style languages is octal 493, not decimal 755.
- Negative numbers are usually two’s complement, not a sign bit. In 8 bits, 11111111 is -1 and 10000000 is -128. To negate a value, invert every bit and add 1.
- Hex digits A to F are case-insensitive as values. #FF0000 and #ff0000 are the same color; only style guides care.
- Byte order is separate from base. The 32-bit value 0x12345678 can be stored as 12 34 56 78 or 78 56 34 12 depending on endianness, which is why a hex dump can look scrambled.
Convert values outside this table
These tables stop where usefulness stops. For anything larger — a 32-bit mask, a hash fragment, an arbitrary integer — the Base Converter on this site converts between binary, octal, decimal and hexadecimal in any direction as you type, and shows all four at once so you can check your own hand work against it. It runs fully in your browser, with nothing sent to a server.