Number base converter
255, FF and 11111111 are the same number. Convert between decimal, binary, octal and hexadecimal, plus base 3, 12 and 36, Gray code and BCD, typing in whichever base you have.
That's 2.8× as big as a nibble (4 bits), while a byte is 6.1× bigger. That needs 6 bits to store.
What it means
How big is that?
Whole numbers only. Anything after the decimal point is rounded away.
Every unit
Your number in every base
Learn
Three things worth knowing
-
One hex digit is four bits
F is 1111, and FF is 11111111, which is 255. That is why colors are written #FF8800: three bytes, two hex digits each.
-
Why octal existed
Early computers used 12, 24 or 36-bit words, all divisible by three, so octal grouped the bits neatly. When 8-bit bytes won, hexadecimal took over.
-
0x, 0b and leading zeros
A leading 0 means octal in some languages, so 010 is 8 rather than 10. Prefixes 0x and 0b exist to remove the guesswork.
Quick answers
Questions people ask about number
- How do I convert binary to decimal?
- Add the powers of two where there is a 1, from the right: 1010 is 8 + 2 = 10, and 11111111 is 255. Each binary digit doubles the value of the one to its right.
- What is FF in decimal?
- 255. In hexadecimal, F is 15, so FF is 15 × 16 + 15. That is why colors like #FFFFFF run from 00 to FF for each of red, green and blue.
- Why do programmers use hexadecimal?
- One hex digit stands for exactly four bits, so a byte is always two hex digits (00 to FF). It is much shorter than binary and still maps bit for bit.
- What is octal used for?
- Mainly Unix file permissions: chmod 755 means rwx for the owner (7 = 4 + 2 + 1) and r-x for everyone else (5 = 4 + 1). Each octal digit is three bits.
Keep going
What people use next
Shortcuts
Popular number conversions
Background
About number bases
Decimal counts in tens because we have ten fingers. Computers count in binary, because a wire is either on or off. Hexadecimal is shorthand for binary: one hex digit is exactly four bits, so a byte is always two hex digits.