Developer Bases

Hex to decimal

Hexadecimal value
Decimal 255
Each hex digit is four bits
The same number elsewhere
Binary 11111111
Binary, grouped 1111 1111
Octal 377
Hexadecimal FF
Bits needed 8
Note
One hex digit = four bits
DecimalBinaryOctalHex
0000
1111
81000108
10101012A
15111117F
16100002010
64100000010040
100110010014464
25511111111377FF
256100000000400100
1024100000000002000400
655351111111111111111177777FFFF

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.

Advertisement
320 × 100

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

1 Enter the hexadecimal value. A 0x prefix and spaces are accepted.
2 Read the decimal result, with binary and octal beneath it.
3 A letter above F is rejected rather than silently ignored.
4 Use the table for the values worth recognising on sight.

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.

Advertisement
300 × 250
Was this tool any good?
INTERNAL SIGNAL ONLY · WE USE IT TO FIND TOOLS WORTH REBUILDING