Converting Hexadecimal to Binary
Learn the direct hex-to-binary conversion method where each hex digit maps to exactly 4 binary bits. Master the nibble table for instant conversions.
Hex
4F = 0100 1111
ASCII
Base-16 → Base-2
Detailed Explanation
Hexadecimal-to-binary conversion is the simplest of all number base conversions because each hex digit maps directly to exactly four binary digits (bits). This is not a coincidence — hexadecimal was specifically designed as a compact notation for binary data, since 16 = 2⁴.
The nibble table — memorize this:
A "nibble" is a group of 4 bits. Each hex digit corresponds to one nibble:
| Hex | Binary | Hex | Binary |
|---|---|---|---|
| 0 | 0000 |
8 | 1000 |
| 1 | 0001 |
9 | 1001 |
| 2 | 0010 |
A | 1010 |
| 3 | 0011 |
B | 1011 |
| 4 | 0100 |
C | 1100 |
| 5 | 0101 |
D | 1101 |
| 6 | 0110 |
E | 1110 |
| 7 | 0111 |
F | 1111 |
Conversion method:
Simply replace each hex digit with its 4-bit binary equivalent. No arithmetic required.
Example — converting 4F to binary:
4→0100F→1111- Result:
0100 1111
Example — converting A3 to binary:
A→10103→0011- Result:
1010 0011
Example — converting FF to binary:
F→1111F→1111- Result:
1111 1111(all 8 bits set = 255 in decimal)
Why hex and binary are naturally linked:
One byte (8 bits) is represented by exactly two hex digits. One hex digit represents exactly one nibble (4 bits). This 1:1 mapping is why hex is the preferred notation for binary data — it is four times more compact than binary while maintaining a trivial conversion path. Writing memory addresses, bitfield values, or register contents in hex is far more readable than binary, yet no information is lost.
Practical applications:
- Bitfield analysis: When a hex value like
0x83represents a flags byte, converting to binary (1000 0011) immediately shows which bits are set (bits 7, 1, and 0) - Subnet masks: The mask
FF FF FF 00converts to11111111 11111111 11111111 00000000, making the /24 prefix visible - Permissions: Unix file permissions like
0755in octal are more readable in binary to see individual rwx bits - Color channels: The hex color
#3Cfor one channel is0011 1100in binary, showing 4 high bits off and the middle bits on
Converting back (binary to hex):
Group binary digits into sets of 4 from right to left, then look up each group in the nibble table. For example, 110101 becomes 0011 0101 (padded to 8 bits) = 35 in hex.
Use Case
Hex-to-binary conversion is used when analyzing CPU register flags, interpreting network protocol bitfields, understanding file permission masks, and debugging hardware communication at the bit level.