Hex to decimal
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 64 | 1000000 | 100 | 40 |
| 100 | 1100100 | 144 | 64 |
| 255 | 11111111 | 377 | FF |
| 256 | 100000000 | 400 | 100 |
| 1024 | 10000000000 | 2000 | 400 |
| 65535 | 1111111111111111 | 177777 | FFFF |
One hexadecimal digit maps exactly onto four binary digits, so a byte is always two hex characters and the mapping never has a remainder. That is the entire reason hex won over octal for computing: octal groups three bits, which does not divide an eight-bit byte evenly, so an octal byte needs two and two thirds digits.
Hexadecimal is base 16, using 0–9 then A–F. Each digit is worth sixteen times the one to its right, so FF is 15 × 16 + 15 = 255. One hex digit maps exactly onto four bits.
How to convert hex to decimal
Doing it by hand is worth knowing once. Take each digit, multiply by 16 raised to its position from the right, and add: 2AF is 2×256 + 10×16 + 15 = 687. In practice the useful skill is recognising the landmarks; FF is 255, FFFF is 65535, 80 is 128, and 0x20 is a space in ASCII. Those five turn up constantly in colour values, memory addresses and file dumps.
Questions
255. It is the largest value a single byte can hold, which is why it appears everywhere.
Base 16 needs sixteen digit symbols and there are only ten numerals, so A to F stand for 10 to 15.
It marks a number as hexadecimal in most programming languages. This tool accepts it and ignores it.
One hex digit is exactly four bits, so a byte is always two hex characters.
No. FF and ff are the same value; uppercase is the more common convention.