How to convert binary to decimal
Each digit in a binary number stands for a power of 2. The rightmost digit is worth 1, the next 2, then 4, 8, 16 and so on, doubling each time. To convert, multiply each digit by its place value and add the results.
For example, 1011 in binary is 1×8 + 0×4 + 1×2 + 1×1 = 11 in decimal. And 11111111 is 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255, the largest value a single byte can hold.
How to convert decimal to binary
Divide the number by 2 and write down the remainder, which is 0 or 1. Keep dividing the answer by 2 until you reach 0. Then read the remainders from the last one to the first.
For 13: 13 ÷ 2 = 6 remainder 1, 6 ÷ 2 = 3 remainder 0, 3 ÷ 2 = 1 remainder 1, and 1 ÷ 2 = 0 remainder 1. Reading up gives 1101. To do this in the converter, choose Decimal as the input or press Swap.
Binary, decimal and hex from 0 to 15
| Decimal | Binary | Hex |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 2 | 0010 | 2 |
| 3 | 0011 | 3 |
| 4 | 0100 | 4 |
| 5 | 0101 | 5 |
| 6 | 0110 | 6 |
| 7 | 0111 | 7 |
| 8 | 1000 | 8 |
| 9 | 1001 | 9 |
| 10 | 1010 | A |
| 11 | 1011 | B |
| 12 | 1100 | C |
| 13 | 1101 | D |
| 14 | 1110 | E |
| 15 | 1111 | F |
Why hex and octal are handy
One hex digit stands for exactly four binary digits, so programmers use hex as a short way to write binary. The byte 1111 0000 is F0 in hex. Octal does the same with groups of three digits, and it still appears in Unix file permissions, such as 755.
Long numbers stay exact
The converter works with whole numbers of up to 256 digits without rounding, so 64-bit and 128-bit values convert exactly. It accepts prefixes such as 0b, 0x and 0o, and ignores spaces and underscores, so you can paste values straight from code. Negative numbers and fractions aren’t supported, as computers store those in several different ways.
For encoding text rather than numbers, try the Base64 encoder and decoder.
How to use the binary to decimal converter
- Type the number in “Number to convert”. You can paste it with spaces, underscores or commas between digit groups.
- Tell the tool what it is in. Under “It is in”, pick Binary, Decimal, Hexadecimal or Octal.
- Press Convert. A binary, hex or octal number is shown in decimal. A decimal number is shown in binary.
- Read the table for the same value in all four bases and the number of bits it needs. Press “Swap binary and decimal” to turn the answer into the new input.
Worked example: 11001010 in decimal
Type 11001010 with Binary selected and press Convert. The answer is 202, and the working line shows each digit times its place value:
1×128 + 1×64 + 0×32 + 0×16 + 1×8 + 0×4 + 1×2 + 0×1 = 202
The table adds the other bases. Hexadecimal is CA, octal is 312 and the bits needed are 8, so this value fits in one byte. The working line appears for numbers of up to 16 bits. Longer numbers still convert, but the sum would be too long to read.
Worked example: 2026 in binary
Choose Decimal, type 2026 and press Convert. The answer is 111 1110 1010. The tool groups binary digits in fours from the right, which makes long numbers easier to read and lines them up with hex. Each group of four is one hex digit: 111 is 7, 1110 is E and 1010 is A, so the hex row shows 7EA. The octal row shows 3752, and the bits needed are 11. As a check, the working line adds up 1024 + 512 + 256 + 128 + 64 + 32 + 8 + 2, which is 2026.
Reading the bits needed row
“Bits needed” counts the binary digits of the number without leading zeros. It tells you the smallest storage size that can hold the value. 255 needs 8 bits, so it fits in one byte, but 256 needs 9 bits and spills into a second byte. Two bytes hold whole numbers up to 65,535, and four bytes hold up to 4,294,967,295. When you pick a field size for a file format, a database column or a microcontroller register, check this row first, then add a sign bit if the value can ever be negative.
Octal and file permissions
Octal works the same way with groups of three bits. Choose Octal and enter 755. The decimal answer is 493, and the binary row reads 1 1110 1101. Split that into threes from the right instead and you get 111 101 101, which is 7, 5 and 5. Each three-bit group becomes one octal digit, which is why permission codes such as 755 are so short. To turn those digits into readable permissions, try the chmod calculator.
Why big numbers need special care
Ordinary JavaScript numbers can’t hold every large whole number exactly. MDN warns that a number string larger than Number.MAX_SAFE_INTEGER loses precision when converted the usual way, and suggests using BigInt.[1] BigInt values are built for whole numbers that are too large for the normal number type.[2] This converter reads every digit into a BigInt, so nothing is rounded.
For example, enter FFFF_FFFF_FFFF_FFFF as hexadecimal. The decimal answer is 18,446,744,073,709,551,615, the largest value a 64-bit unsigned number can hold, and the bits needed are 64. Enter 9007199254740993 as decimal and the hex row shows 20 0000 0000 0001, exact to the last digit. A converter built on ordinary numbers would round that value down by one.
Common mistakes
- Wrong base selected. The digits 10 mean ten in decimal but two in binary. Check “It is in” before you press Convert.
- Expecting leading zeros. 00001010 and 1010 are the same number, so the result drops the zeros. Pad the binary yourself if you need a fixed width.
- Negative numbers. Computers store them in more than one way. MDN notes that JavaScript writes a negative number in binary as a minus sign and the positive digits, not as two’s complement.[1] This tool takes whole numbers from zero up.
To add, subtract or multiply binary numbers, use the binary calculator. For AND, OR and XOR, use the bitwise calculator. For bases other than 2, 8, 10 and 16, try the base converter.
What next
Use this often? Add Binary to De to your Home screen.
Frequently asked questions
What is 1010 in decimal?
1010 in binary is 10 in decimal: 1×8 + 0×4 + 1×2 + 0×1 = 10.
What is 255 in binary?
255 is 11111111 in binary, eight 1s. It is the largest number one byte can hold, and FF in hex.
How many decimal values can 8 bits hold?
256 values, from 0 to 255, because 2 to the power of 8 is 256.
Can I convert hex to decimal here?
Yes. Choose Hexadecimal as the input base, and the result shows decimal, binary and octal.
What is 2026 in binary?
2026 is 11111101010 in binary, which the tool shows as 111 1110 1010. It is 7EA in hex and 3752 in octal, and it needs 11 bits.
Why does the working line disappear for long numbers?
The place-value sum is shown for binary numbers of up to 16 digits. Longer numbers still convert exactly, but the sum would be too long to read, so only the answer and the table are shown.
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.