Binary, Octal, Decimal and Hex Conversion Table

Binary, octal, decimal and hex side by side, from 0 to 65536.

No signup, no tracking

Computers 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.

DecimalBinary (4 bits)OctalHex
0000000
1000111
2001022
3001133
4010044
5010155
6011066
7011177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F

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.

DecimalBinaryOctalHex
0000
1111
21022
31133
410044
510155
611066
711177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F
16100002010
17100012111
18100102212
19100112313
20101002414
21101012515
22101102616
23101112717
24110003018
25110013119
2611010321A
2711011331B
2811100341C
2911101351D
3011110361E
3111111371F
321000004020

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.

PowerDecimalBinaryHex
2^0111
2^12102
2^241004
2^3810008
2^4161000010
2^53210000020
2^664100000040
2^71281000000080
2^8256100000000100
2^95121000000000200
2^101,02410000000000400
2^112,048100000000000800
2^124,09610000000000001000
2^138,192100000000000002000
2^1416,3841000000000000004000
2^1532,76810000000000000008000
2^1665,5361000000000000000010000

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.

DecimalBinary (8 bits)HexWhat it is
00000000000Null byte
90000100109Tab
10000010100ALine feed (LF, Unix newline)
13000011010DCarriage return (CR)
27000110111BEscape — starts ANSI terminal codes
320010000020Space
480011000030Digit "0"
570011100139Digit "9"
650100000141Letter "A"
90010110105ALetter "Z"
970110000161Letter "a"
122011110107ALetter "z"
127011111117FDEL — last 7-bit ASCII value
1281000000080First byte outside ASCII; INT8 minimum in two’s complement
16010100000A0Non-breaking space in Latin-1
19110111111BFUpper bound of UTF-8 continuation bytes
19211000000C0Common subnet mask octet (/26)
22411100000E0Subnet mask octet (/27)
24011110000F0Subnet mask octet (/28); high nibble set
25411111110FEHighest usable octet in many networks
25511111111FFUINT8 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.

  1. 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.
  2. Decimal to binary: divide by 2 repeatedly, writing down each remainder, until the quotient reaches 0. Read the remainders bottom to top.
  3. 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.
  4. Hex to binary: replace each hex digit with its four-bit pattern and concatenate. No carrying, no arithmetic.
  5. 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) = 156
Add the powers of two wherever a bit is 1
Decimal 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: 10011100
Repeated division by 2
Binary to hex: 11001010
1100 1010  →  C A  →  0xCA
Split into nibbles, then look each one up
Hex to decimal: 0x2F
2 × 16 + 15 = 47

Binary to octal: 10011100
010 011 100  →  2 3 4  →  0o234
Positional weighting, and grouping in threes for octal

Gotchas

  1. 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.
  2. 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.
  3. 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.
  4. Hex digits A to F are case-insensitive as values. #FF0000 and #ff0000 are the same color; only style guides care.
  5. 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.

Related tools