Binary, Decimal, Hex: A Practical Cheat Sheet for Developers
Binary, decimal, and hex cheat sheet with a searchable 0-255 table, nibble mapping, powers of two, common masks, prefixes, and worked examples.
When you are reading bytes, packet fields, registers, color values, or debug output, the fastest route is often a compact reference instead of doing every conversion from scratch.
This page combines the mappings that matter most: binary, decimal, and hexadecimal from 0 through 255, plus powers of two, nibble patterns, prefixes, common masks, and conversion examples.
Binary, Decimal, and Hex at a Glance
- Binary is base 2 and uses
0and1. - Decimal is base 10 and uses digits
0-9. - Hexadecimal is base 16 and uses
0-9plusA-F. - 1 hex digit = 4 bits (one nibble).
- 2 hex digits = 8 bits (one byte).
- One unsigned byte ranges from decimal
0to255, hex0x00to0xFF, and binary00000000to11111111.
Binary / Decimal / Hex Table: 0-255
Use the reference below to search by decimal, 0x hexadecimal, raw hex, or 8-bit binary. The table is split into four collapsible ranges so you can keep only the section you need open. Click a numeric value to copy it.
256 values available. Click any numeric value to copy it.
0-63 0x00-0x3F
| Decimal | Hex | Binary (8-bit) | Reference note |
|---|---|---|---|
| Zero / null value | |||
| Lowest non-zero bit | |||
| 2^1 | |||
| 2^2 | |||
| 2^3 | |||
| 2^4 | |||
| 2^5 | |||
64-127 0x40-0x7F
| Decimal | Hex | Binary (8-bit) | Reference note |
|---|---|---|---|
| 2^6 | |||
| Largest positive signed 8-bit value |
128-191 0x80-0xBF
| Decimal | Hex | Binary (8-bit) | Reference note |
|---|---|---|---|
| Highest bit in one byte | |||
192-255 0xC0-0xFF
| Decimal | Hex | Binary (8-bit) | Reference note |
|---|---|---|---|
| All 8 bits set / 0xFF |
Powers of Two
Binary place values are powers of two. For an 8-bit byte, the columns run from 2^7 down to 2^0.
| Power | Decimal | Binary | Hex |
|---|---|---|---|
2^0 |
1 | 00000001 |
0x01 |
2^1 |
2 | 00000010 |
0x02 |
2^2 |
4 | 00000100 |
0x04 |
2^3 |
8 | 00001000 |
0x08 |
2^4 |
16 | 00010000 |
0x10 |
2^5 |
32 | 00100000 |
0x20 |
2^6 |
64 | 01000000 |
0x40 |
2^7 |
128 | 10000000 |
0x80 |
These are also the single-bit masks for each position in one byte.
4-Bit Nibble Table
Because each hex digit corresponds to exactly four binary bits, this 16-row table is the fastest manual binary-to-hex lookup.
| Decimal | Binary | Hex |
|---|---|---|
| 0 | 0000 |
0 |
| 1 | 0001 |
1 |
| 2 | 0010 |
2 |
| 3 | 0011 |
3 |
| 4 | 0100 |
4 |
| 5 | 0101 |
5 |
| 6 | 0110 |
6 |
| 7 | 0111 |
7 |
| 8 | 1000 |
8 |
| 9 | 1001 |
9 |
| 10 | 1010 |
A |
| 11 | 1011 |
B |
| 12 | 1100 |
C |
| 13 | 1101 |
D |
| 14 | 1110 |
E |
| 15 | 1111 |
F |
For example, split 10101100 into 1010 1100. The two nibbles map to A and C, so the result is 0xAC.
Prefixes: 0b and 0x
Programming languages and technical documentation often use prefixes so the base is obvious:
0b101010means binary101010.0x2Ameans hexadecimal2A.42usually means decimal 42 when no other base marker is present.
The prefixes are notation, not extra digits in the number itself. The values 0b00101010, 0x2A, and decimal 42 are equal.
Common 8-Bit Values
These values appear frequently enough to memorize or keep close at hand.
| Decimal | Hex | Binary | Why it matters |
|---|---|---|---|
| 0 | 0x00 |
00000000 |
No bits set |
| 1 | 0x01 |
00000001 |
Lowest bit set |
| 2 | 0x02 |
00000010 |
Power of two |
| 4 | 0x04 |
00000100 |
Power of two |
| 8 | 0x08 |
00001000 |
Power of two |
| 16 | 0x10 |
00010000 |
First bit of high nibble |
| 32 | 0x20 |
00100000 |
Power of two; ASCII space is decimal 32 |
| 64 | 0x40 |
01000000 |
Power of two |
| 127 | 0x7F |
01111111 |
Largest positive signed 8-bit value |
| 128 | 0x80 |
10000000 |
Highest bit in one byte |
| 255 | 0xFF |
11111111 |
Every bit set |
Common Masks
A bit mask keeps, clears, or tests selected bits. Three byte-sized masks are especially common:
| Mask | Binary | Typical use |
|---|---|---|
0xFF |
11111111 |
Keep the low 8 bits / represent all bits set |
0x0F |
00001111 |
Select the low nibble |
0xF0 |
11110000 |
Select the high nibble |
For example, value & 0x0F keeps only the lowest four bits of value.
Worked Examples
Binary to Hex
11110000 → split as 1111 0000 → F 0 → 0xF0.
Use the Binary to Hex converter when the value is longer or you want an instant check.
Hex to Binary
0x2A → 2 is 0010, A is 1010 → 00101010.
Use Hex to Binary for larger values.
Binary to Decimal
00101010 has the 32, 8, and 2 positions set:
32 + 8 + 2 = 42
Check it with Binary to Decimal.
Decimal to Binary
Decimal 42 can be decomposed as 32 + 8 + 2, so the corresponding 8-bit pattern is 00101010.
Check it with Decimal to Binary.
8-Bit Byte Examples
| Decimal | Hex | Binary |
|---|---|---|
| 42 | 0x2A |
00101010 |
| 85 | 0x55 |
01010101 |
| 170 | 0xAA |
10101010 |
| 240 | 0xF0 |
11110000 |
| 255 | 0xFF |
11111111 |
For conversions outside the common base-2/base-10/base-16 workflow, use the Base 2-62 Converter.