Number Bases Explained: Binary, Octal, Decimal and Hexadecimal
Programmers switch between bases all day. This guide explains how binary, octal, decimal and hexadecimal relate, with simple conversions.
What is the Base Converter?
Different bases count the same value with different digits: binary uses only 0 and 1, octal uses 0 to 7, decimal uses 0 to 9, and hexadecimal adds letters A to F. This tool converts a whole number from any of those bases to any other, and rejects digits that do not belong in the chosen base. It handles whole numbers only, not fractions, and very large numbers may lose precision because of how JavaScript stores numbers.
How to use it
- Enter the number to convert.
- Pick the base it is currently in and the base you want.
- Press Convert to see the result.
Worked example
255 in decimal converts to FF in hexadecimal.
How do I convert decimal to hexadecimal by hand?
Divide by 16 repeatedly and keep the remainders, then read them backwards, using A to F for remainders 10 to 15. For example, 255 divided by 16 gives 15 remainder 15, which is FF.
Frequently asked questions
What digits can I use in hexadecimal?
Digits 0 to 9 plus letters A to F, in either upper or lower case. Letters beyond F are not valid hex digits.
Can I convert fractions like 10.5?
No. This tool converts whole numbers only. Fractions need a separate fractional conversion, since the part after the point works differently.