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 It 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
Loading code...Frequently Asked Questions
Why is hexadecimal used in computing instead of decimal?
Hexadecimal is used because it maps perfectly to binary - each hex digit represents exactly 4 bits. This makes conversion between binary and hex trivial, and hex is much more compact than binary while still maintaining a direct relationship. For example, a byte (8 bits) can be represented by just 2 hex digits instead of 8 binary digits.
How do I convert hexadecimal to decimal manually?
To convert hex to decimal, multiply each digit by 16 raised to its position power (starting from 0 on the right) and sum the results. For example, 2A in hex: A(10) × 16^0 + 2 × 16^1 = 10 + 32 = 42 in decimal. For letters, A=10, B=11, C=12, D=13, E=14, F=15.
What do the prefixes 0x and # mean in hexadecimal notation?
The 0x prefix is used in programming languages like C, JavaScript, and Python to indicate a hexadecimal number (e.g., 0xFF = 255). The # prefix is specifically used for color codes in CSS and HTML (e.g., #FF0000 for red). Some assembly languages use the 'h' suffix instead (e.g., FFh).
Why does hexadecimal use letters A through F?
Hexadecimal needs 16 unique symbols to represent values 0-15, but we only have 10 numeric digits (0-9). The letters A-F were chosen to represent values 10-15 because they are sequential, easy to remember, and were already available on keyboards. This keeps the notation compact while allowing any value to be represented.
How is hexadecimal used in memory addresses and debugging?
Memory addresses are typically displayed in hexadecimal because they are based on binary and can be extremely large. Hex makes these addresses more readable and easier to work with. For example, a 64-bit address like 0x00007FF7A8B4C000 is much more manageable than its decimal equivalent. Debuggers use hex to display memory contents, making it easy to spot patterns and byte boundaries.