How to use the Number Base Converter (Binary, Decimal, Hex)
- Type the number. You can include a prefix such as 0x or 0b, or spaces, and they will be ignored.
- Choose the base of the number you typed.
- Read the binary, octal, decimal and hexadecimal forms.
- If you see an error, check that every digit is valid for the base you chose.
Formula used
Each digit is multiplied by the base raised to its position, from the right starting at 0, and the products are added. To convert from decimal, divide repeatedly by the new base and read the remainders upwards.
Worked example
Here is the Number Base Converter (Binary, Decimal, Hex) worked through with the example values shown above, so you can check each step by hand.
| Inputs | |
|---|---|
| Number | 255 |
| Base of the number you typed | Decimal (base 10) |
| Result | |
| Binary (base 2) | 1111 1111 |
| Octal (base 8) | 377 |
| Decimal (base 10) | 255 |
| Hexadecimal (base 16) | FF |
How bases work
In any base, each digit is worth a power of the base, counting from the right starting at 0. In binary, 1010 is 1×8 + 0×4 + 1×2 + 0×1 = 10. In hexadecimal, FF is 15×16 + 15 = 255. Decimal 255 is 1111 1111 in binary, 377 in octal and FF in hexadecimal.
Hexadecimal uses the letters A to F for the values 10 to 15, so its digits run from 0 to F.
Converting by hand
To convert from decimal to another base, divide by the base repeatedly and write the remainders from last to first. For 13 in binary: 13 ÷ 2 = 6 remainder 1, 6 ÷ 2 = 3 remainder 0, 3 ÷ 2 = 1 remainder 1, 1 ÷ 2 = 0 remainder 1. Reading upwards gives 1101.
To go to decimal, multiply each digit by its power of the base and add. Between binary and hex, group the bits in fours: each group of four bits is one hex digit.
Why programmers use hex
One hex digit is exactly four bits, so hex is a compact, readable form of binary. A byte is two hex digits, 00 to FF. Colour codes use this: the web colour FF00FF is magenta, made of red FF, green 00 and blue FF, and as a number it equals 16711935.
Octal groups bits in threes and appears in Unix file permissions, such as 755.
Limits
This converter handles non-negative and negative whole numbers up to 300 digits. It does not convert fractions such as binary 101.01. Binary output is shown in groups of four bits for readability.
For other conversions, such as text to binary or floating-point formats, a specialised tool is needed. The data storage converter on this site converts units such as bytes, kilobytes and gigabytes.
Frequently asked questions
How do I convert binary to decimal?
Add the powers of two for each 1 bit. 1101 is 8 + 4 + 1 = 13.
How do I convert hex to binary?
Convert each hex digit to four bits: F is 1111, A is 1010.
What are the digits in hexadecimal?
0 to 9 and A to F, where A is 10 and F is 15.
Can it convert negative numbers?
Yes. Put a minus sign in front. It shows the sign with the magnitude, not two’s complement.
Does it handle large numbers?
Yes, up to 300 digits, converted exactly.
Why does it say a digit is invalid?
Each base allows only certain digits. Binary allows 0 and 1, octal 0 to 7 and hex 0 to 9 and A to F.
This calculator gives estimates for information only. Actual figures from a bank, employer, tax authority or doctor may differ. It is not financial, tax, legal or medical advice.