💻 Developer#2진수#16진수#진법
Binary and Hexadecimal Basics for Debugging
4 min read · Last updated: 2026-05-08
Number system fundamentals
Computers process all data internally as binary (base-2). Hexadecimal (base-16) groups 4 bits into a single digit, making binary data far more readable for humans.
Number system comparison
| Decimal | Binary | Hexadecimal |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 2 | 0010 | 2 |
| 5 | 0101 | 5 |
| 8 | 1000 | 8 |
| 10 | 1010 | A |
| 15 | 1111 | F |
| 16 | 0001 0000 | 10 |
| 255 | 1111 1111 | FF |
Conversion methods
Decimal → Binary: Repeatedly divide by 2 and read remainders in reverse.
Example: 13 → 1101₂ (13÷2=6r1 → 6÷2=3r0 → 3÷2=1r1 → 1÷2=0r1 → read remainders upward)
Binary → Hex: Group bits in sets of 4 from the right; convert each group.
Example: 1101 0011₂ → D3₁₆
Hex → Decimal: Multiply each digit by its power of 16 and sum.
Example: 0xFF = 15×16 + 15 = 255
Practical debugging examples
- Bitmask check: flag
0x05 = 0000 0101₂→ bits 0 and 2 are set - Memory address:
0x00FF1234→ byte offset 16,712,244 - Color code:
#1A2B3C= R:26, G:43, B:60 - Extract lower nibble with AND:
0xAF & 0x0F = 0x0F
Key takeaways
- 4 binary digits = 1 hexadecimal digit.
- The
0xor#prefix denotes hexadecimal. - Understanding bitwise operations (AND, OR, XOR, shifts) unlocks hardware register and protocol analysis.
- Colors, addresses, flags, and error codes are all commonly expressed in hex.