Binary and Hex Converter
Type a whole number, say which base it is in and which base you want. You get the converted number and the same number in binary, octal, decimal and hexadecimal.
Your numbers
How we calculate it
A number in base b is a sum of digits times powers of b. The digits are 0 to 9 and then A to Z for 10 to 35, so base 16 uses 0 to 9 and A to F, and base 36 uses every letter. The calculator reads your number one digit at a time, builds its value, and then writes that value in the base you chose.
So FF in base 16 is 15 × 16 + 15 = 255, and 255 in base 2 is 11111111. It works for whole numbers up to 9,007,199,254,740,991 (2^53 − 1), the largest integer that can be stored exactly. A leading minus sign is allowed, and you may start the number with 0x, 0b or 0o when the base is 16, 2 or 8.
Assumptions and limits
- Letters can be typed in lower or upper case. The result is always shown in capitals.
- Fractions such as 10.5 are not converted. Only whole numbers are supported.
- This is the plain base conversion of a signed number. It does not show two's complement bit patterns or a fixed width such as 8 bits.
Frequently asked questions
How do I convert binary to decimal?
Add up the powers of 2 for each 1. For example 1010 is 8 + 2 = 10. Choose base 2 for the number and base 10 for the result and the calculator does the sum for you.
How do I convert hexadecimal to binary?
Each hexadecimal digit is exactly four binary digits. F is 1111 and A is 1010, so FA is 11111010. Choose base 16 to base 2 to check any value.
What is the largest number I can convert?
The limit is 9,007,199,254,740,991, which is 2^53 − 1 or 1FFFFFFFFFFFFF in hexadecimal. Larger values cannot be stored exactly, so the calculator stops and tells you instead of showing a wrong answer.
Related calculators
- Data Storage ConverterEnter an amount of data, choose the unit it is in and the unit you want.
- Hex to RGB Color ConverterType a color as hex, rgb() or hsl().
- Subnet CalculatorEnter an IPv4 address and the prefix length (the number after the slash, such as 24).
- Roman Numeral ConverterChoose which way you want to convert, then enter a number or a Roman numeral.
Worked example (a fixed example using the starting numbers, it does not change as you type)
Inputs: Number to convert = 255; From base = Base 10 (decimal); To base = Base 16 (hexadecimal).
- Result FF
- Conversion 255 (base 10) = FF (base 16)
Embed this calculator
Add this calculator to your own page. Paste the code where you want it. The small link keeps credit to the source.