What is Hexadecimal?
Hexadecimal (also known as hex or base-16) is a positional numeral system that uses 16 distinct symbols: digits 0-9 represent values 0-9, and letters A-F (or a-f) represent values 10-15. It provides a human-friendly way to represent binary data.
Quick Facts
| Full Name | Hexadecimal Number System |
|---|---|
| Created | Ancient origins, computing use from 1960s |
| Specification | Official Specification |
How Hexadecimal Works
Hexadecimal is widely used in computing because it maps perfectly to binary - each hex digit represents exactly 4 bits (a nibble). This makes it easy to convert between binary and hex, and more compact than binary for human reading. Hex is commonly used for memory addresses, color codes in web design (#FF5733), MAC addresses, and representing byte values. In programming, hex numbers are typically prefixed with 0x (e.g., 0xFF) or # for colors.
Key Characteristics
- Base-16 number system (0-9, A-F)
- Each digit represents 4 binary bits
- More compact than binary representation
- Common prefixes: 0x, #, or suffix h
- Case-insensitive (A-F same as a-f)
- Perfect for representing byte values (00-FF)
Common Use Cases
- Web color codes (#RRGGBB)
- Memory addresses in debugging
- MAC addresses (00:1A:2B:3C:4D:5E)
- Binary data representation
- Cryptographic hash display
Example
Hexadecimal Conversion:
Decimal Binary Hex
0 0000 0
9 1001 9
10 1010 A
15 1111 F
16 0001 0000 10
255 1111 1111 FF
256 0001 0000 0000 100
Color Examples:
#FF0000 = Red (R:255, G:0, B:0)
#00FF00 = Green (R:0, G:255, B:0)
#0000FF = Blue (R:0, G:0, B:255)
#FFFFFF = White
#000000 = Black
Conversion formulas:
Hex to Decimal: parseInt('FF', 16) = 255
Decimal to Hex: (255).toString(16) = 'ff'