Computer ScienceAlso called: "hex", "base16", "hexadecimal notation"
Hexadecimal (hex) provides human-readable representation of binary data.
Why hex is used
- Compact: 1 hex digit = 4 bits, 2 hex digits = 1 byte.
- Readable: Easier than binary (11111111 vs FF).
- Alignment: Matches byte boundaries perfectly.
Common uses
- Color codes: #FF5733 (RGB values in hex).
- Memory addresses: 0x7FFF5FBFF710.
- Character encodings: \x41 = 'A'.
- Hash values: SHA-256 outputs as hex strings.
- MAC addresses: 00:1A:2B:3C:4D:5E.
Conversion
- Decimal 255 = Hex FF = Binary 11111111
- Decimal 16 = Hex 10 = Binary 00010000
- Decimal 42 = Hex 2A = Binary 00101010
Prefixes
- 0x prefix (C, JavaScript): 0xFF
- # prefix (CSS colors): #FF5733
- \x prefix (escape sequences): \x41