Cheat Sheets Data & Encoding

Binary, Octal & Hex Table Cheat Sheet

0 to 31 in decimal, binary, octal and hex, the powers of two, hand-conversion shortcuts and the Base32 alphabet, with links to every converter.

Last reviewed:

AdSense Placeholder
Slot: header_reference_page
On this page

How the same number is written in the four bases programmers use, with the quick conversion methods. For the full explanation read How Number Bases Work: Binary, Octal and Hex; to convert any value use the Number Base Converter.

0 to 31 in four bases

Decimal Binary Octal Hex Decimal Binary Octal Hex
0 0000 0 0 16 10000 20 10
1 0001 1 1 17 10001 21 11
2 0010 2 2 18 10010 22 12
3 0011 3 3 19 10011 23 13
4 0100 4 4 20 10100 24 14
5 0101 5 5 21 10101 25 15
6 0110 6 6 22 10110 26 16
7 0111 7 7 23 10111 27 17
8 1000 10 8 24 11000 30 18
9 1001 11 9 25 11001 31 19
10 1010 12 A 26 11010 32 1A
11 1011 13 B 27 11011 33 1B
12 1100 14 C 28 11100 34 1C
13 1101 15 D 29 11101 35 1D
14 1110 16 E 30 11110 36 1E
15 1111 17 F 31 11111 37 1F

Powers of two

Power Value Common name
2^0 1
2^1 2
2^2 4
2^3 8
2^4 16
2^5 32
2^6 64
2^7 128 Largest signed byte + 1
2^8 256 Values in a byte
2^9 512
2^10 1,024 1 KiB
2^12 4,096
2^16 65,536 Values in 16 bits
2^20 1,048,576 1 MiB
2^24 16,777,216
2^30 1,073,741,824 1 GiB
2^32 4,294,967,296 Values in 32 bits (IPv4 addresses)

Converting by hand

  • Decimal to binary: divide by 2 repeatedly and read the remainders from last to first. 202 gives remainders 0 1 0 1 0 0 1 1, which read backwards is 11001010.
  • Binary to hex: group the bits in fours from the right and convert each group: 1100 1010 is C A, so 0xCA.
  • Binary to octal: group in threes: 11 001 010 is 3 1 2, so 312.
  • Check: 202 = 128 + 64 + 8 + 2 = 0xCA = 0o312.

Base32 alphabet

Base32 (like Base64, only with 32 symbols) uses A to Z and 2 to 7, and = pads the end. Hello encodes to JBSWY3DP. Use the Base32 Encode and Base32 Decode.

Quick reference to the converters

Between bases: Binary to HEX Converter, HEX to Binary Converter, Binary to Octal Converter, Octal to Binary Converter, Octal to HEX Converter, HEX to Octal Converter, Octal to Decimal Converter and Decimal to Octal Converter. Between text and a base: Text to Binary Converter, Binary to Text Converter, Binary to ASCII Converter, ASCII to Binary Converter, Text to HEX Converter, HEX to Text Converter, Text to Octal Converter, Octal to Text Converter, Text to Decimal Converter and Decimal to Text Converter. To spell a number out, use the Number to Words Converter.

Try these tools

See also

  • Guide How Number Bases Work: Binary, Octal and Hex
    Place value in binary, octal and hexadecimal, converting 202 between all of them step by step, hex colours.
  • Cheat sheet ASCII Table Cheat Sheet
    All 95 printable ASCII characters with decimal and hex codes, the control characters you will meet.
  • Glossary Binary
    Binary is the base-2 number system, using only the digits 0 and 1, which computers use because electronic circuits are either off or on.
  • Glossary Hexadecimal
    Hexadecimal (hex) is the base-16 number system, using digits 0-9 and letters A-F, widely used as a compact way to write binary data.
AdSense Placeholder
Slot: footer_leaderboard