
When debugging bytes, logs, or packet data, speed matters. This is the cheat sheet I wish every dev had open.
Core Mapping
- Binary is base-2.
- Decimal is base-10.
- Hex is base-16.
Hex is compact and maps cleanly to binary:
- 1 hex digit = 4 bits (one nibble)
- 2 hex digits = 8 bits (one byte)
Instant Nibble Table
| Binary | Hex |
|---|
| 0000 | 0 |
| 0001 | 1 |
| 0010 | 2 |
| 0011 | 3 |
| 0100 | 4 |
| 0101 | 5 |
| 0110 | 6 |
| 0111 | 7 |
| 1000 | 8 |
| 1001 | 9 |
| 1010 | A |
| 1011 | B |
| 1100 | C |
| 1101 | D |
| 1110 | E |
| 1111 | F |
Worked Examples
Example 1: Binary to Hex
11110000 -> split as 1111 0000 -> F0
Example 2: Hex to Binary
2A -> 2 is 0010, A is 1010 -> 00101010
Example 3: Binary to Decimal
00101010 = 32 + 8 + 2 = 42
Example 4: Decimal to Binary
42 = 32 + 8 + 2 -> 00101010
Common Developer Patterns
0xFF as mask for one byte.
0x0F and 0xF0 for low/high nibble operations.
- Byte arrays shown in hex logs (
DE AD BE EF style).
Practice Set
Try converting:
0x7F
10000000
255
0x2A
01010101
Use:
References