Hexadecimal (hex) is base 16. It needs sixteen digit symbols, so after 0–9 it uses letters: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15. Place weights are powers of 16: 1, 16, 256, 4096, …
Hex exists because people are bad at reading long binary. Since 16 = 2⁴, one hex digit is exactly one 4-bit nibble, so converting between hex and binary is a lookup. The 16-bit pattern 1101 0110 0010 1111 is just D62F₁₆.
Where you'll see it:
- memory addresses and register contents in a debugger
- web colors such as
#FF8800(three bytes: red, green, blue) - machine code, error codes and network hardware addresses
In code, hex is usually marked with a 0x prefix: 0x2F = 2F₁₆ = 47. See base notation.
Conversions:
- hex ↔ binary: one digit per 4 bits (binary hex conversion)
- hex → decimal: digit × weight, then add (hex decimal conversion)
- decimal → hex: repeated division by 16
- hex ↔ octal: go through binary (hex octal conversion)