Guide
The Hexadecimal Number System
Place value, counting, arithmetic and signed representation in base 16.
Positional notation
Hexadecimal is positional, which means a digit's value depends on where it sits. Every position is worth sixteen times the position to its right.
| Power | Hex | Decimal |
|---|---|---|
| 160 | 1 | 1 |
| 161 | 10 | 16 |
| 162 | 100 | 256 |
| 163 | 1000 | 4,096 |
| 164 | 10000 | 65,536 |
| 165 | 100000 | 1,048,576 |
| 166 | 1000000 | 16,777,216 |
| 167 | 10000000 | 268,435,456 |
| 168 | 100000000 | 4,294,967,296 |
To evaluate any hex number, multiply each digit by its place value and add. That is the complete definition of the system.
1A2B
1 × 4096 = 4096
A × 256 = 2560
2 × 16 = 32
B × 1 = 11
------
6699
Counting in hex
Counting is where intuition either clicks or does not. The sequence runs normally to 9, continues through the letters, and only then rolls over.
0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 ... ... F0 F1 ... FD FE FF 100
Three landmarks: 10 is sixteen, FF is 255, and 100 is 256.
Once those three feel natural, everything else follows.
Why sixteen and not some other base
The choice is not arbitrary. Bases that are powers of two align with binary; bases that are not do not.
| Base | Bits per digit | Aligns with a byte? |
|---|---|---|
| 2 | 1 | Yes — but eight digits per byte is unreadable |
| 8 | 3 | No — 8 does not divide by 3 |
| 10 | ~3.32 | No — not a power of two at all |
| 16 | 4 | Yes — exactly two digits per byte |
| 32 | 5 | No — 8 does not divide by 5 |
Only base 16 gives a whole number of digits per byte while staying compact. That is the entire reason it won.
Arithmetic
Every rule from decimal carries over. Only the rollover point changes: sixteen rather than ten.
| Operation | Decimal | Hex |
|---|---|---|
| Carry when | A column reaches 10 | A column reaches 16 |
| Borrow brings | 10 | 16 |
| Multiply by base | Append a 0 | Append a 0 (multiplies by 16) |
| Divide by base | Drop last digit | Drop last digit (divides by 16) |
addition subtraction 2F 40 + 1A - 1B ---- ---- 49 25 F + A = 25 0 - B needs a borrow 25 - 16 = 9 16 - 11 = 5 carry 1 4 becomes 3, 3 - 1 = 2
The hex calculator shows this working for any pair of values.
Bit widths
Because every digit is four bits, digit count and bit count are interchangeable.
| Hex digits | Bits | Max unsigned | Signed range |
|---|---|---|---|
| 1 | 4 | 15 | −8 to 7 |
| 2 | 8 | 255 | −128 to 127 |
| 4 | 16 | 65,535 | −32,768 to 32,767 |
| 8 | 32 | 4,294,967,295 | ±2.1 billion |
| 16 | 64 | 1.8 × 1019 | ±9.2 quintillion |
Signed numbers
Hex has no minus sign in practice. Negative values are represented using two's complement at a fixed bit width, which means the width must be known before the value can be read.
- Fix the width — 8, 16, 32 or 64 bits.
- If the leftmost bit of that width is 0, the value is positive and reads normally.
- If it is 1, the value is negative. Subtract 2width to find it.
FF at 8 bits → top bit set → 255 - 256 = -1 FF at 16 bits → top bit clear → 255 80 at 8 bits → top bit set → 128 - 256 = -128 7F at 8 bits → top bit clear → 127
The same eight bits mean 255 or −1 depending entirely on how the surrounding code declares them. The hex to decimal converter switches between readings.
Fractions
Hex fractions exist and follow the same rule: digits after the point are worth
1/16, 1/256, 1/4096 and so on. 0.8 in hex is one half, and 0.4 is one
quarter.
They are rare in practice because floating-point numbers use a different representation altogether — a sign, an exponent and a mantissa, all packed into bits and usually displayed in hex only when someone is debugging the bit pattern itself.
Frequently asked questions
How does place value work in hexadecimal?
Each position is worth sixteen times the position to its right: 1, 16, 256, 4096 and so on. Multiply each digit by its place value and add.
What comes after F in hex?
10, which means sixteen. The sequence is 0 to 9, then A to F, then 10.
Why is base 16 used rather than base 8 or 32?
Sixteen is the only convenient base where one digit is exactly four bits and one byte is exactly two digits. Eight and thirty-two do not divide into a byte evenly.
How does hex arithmetic differ from decimal?
Only in the rollover point. A column carries at sixteen rather than ten, and a borrow brings sixteen across.
How are negative numbers written in hex?
Using two's complement at a fixed bit width. At 8 bits, -1 is FF; at 32 bits the same value is FFFFFFFF.
Can hexadecimal have a fractional part?
Yes. Digits after the point are worth one sixteenth, one 256th and so on. It is rare, because floating point uses a different representation.