Enter a whole number, say which base it is in and which base you want. The result is shown together with its binary, octal, decimal and hexadecimal forms.
Results are estimates for planning. Check the figures before you make a financial or health decision.
How the Binary, hex and decimal converter works
A number in base b is written with digits from 0 up to b − 1, and each position is a power of b. Binary is base 2, octal base 8, decimal base 10 and hexadecimal base 16. Beyond 9, letters stand for digits: A is 10, B is 11 and so on up to Z, which is 35, so the highest base is 36.
The calculator reads your number digit by digit in the starting base, building its value, then writes that value out in the target base. For example, FF in base 16 is 15 × 16 + 15 = 255, which is 11111111 in binary.
It uses big-integer arithmetic, so very long numbers (up to 2,000 digits) convert exactly. Each digit is checked and you are told if one is not valid for the starting base, such as a 2 in binary. A leading minus sign is allowed, and a 0x, 0b or 0o prefix matching the base is ignored. Only whole numbers are supported, not fractions.
Worked example
Using the default values in the calculator above:
| Input | Value |
|---|---|
| Number | 255 |
| From base | 10 |
| To base | 2 |
Base 10 to base 2: 11111111
| Base 2 (binary) | 11111111 |
|---|---|
| Base 8 (octal) | 377 |
| Base 10 (decimal) | 255 |
| Base 16 (hexadecimal) | FF |
| Bits needed (size of the number) | 8 |
Tips and common mistakes
Set the “From base” before you type, then check the digits are legal in it. If you are working with colours, memory addresses or bit flags, the hexadecimal and binary rows of the table are usually what you need.
Case does not matter on input, and the output is in capitals. The bits-needed row shows how many binary digits the number takes, useful when choosing a data size. Leading zeros are ignored.
Frequently asked questions
How do I convert hexadecimal to decimal?
Set From base to 16 and To base to 10, then type the hex number. Each digit is multiplied by a power of 16 and the results are added.
Why can't I use letters in some bases?
Letters are only valid as digits when the base is high enough. Base 16 allows A to F, but binary allows only 0 and 1, so other characters are rejected.
Does it handle negative numbers or fractions?
Negative whole numbers work with a leading minus sign. Fractional values are not supported.