💻 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

DecimalBinaryHexadecimal
000000
100011
200102
501015
810008
101010A
151111F
160001 000010
2551111 1111FF

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 0x or # 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.

Related Tools

🔢
Number Base Converter
Convert numbers between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16) simultaneously.

You might also like

Reading Hex Logs: A Practical Debugging GuideUTF-8 vs CP949: Why Korean Text Gets Garbled