Binary to Decimal Converter

Type or paste a binary number and the decimal value updates on every keystroke. Switch to two's complement to read the same bits as a signed 8, 16, 32 or 64-bit integer, add a binary point for fractions, and check the answer against the place-value sum and the doubling method below the result.

Try

Spaces, underscores, a 0b prefix, a leading minus sign and one binary point are all accepted. Up to 4,096 bits, with 64 of them after the point.

The decimal value shows here

Start typing ones and zeros, or press Load sample to fill the box with 1011 0110.

How a binary number turns into a decimal number

Every position in a binary number stands for a power of 2. The rightmost bit is worth 1, the next one 2, then 4, 8, 16, and each step to the left doubles the weight. Add up the weights under every 1, skip the 0s, and the total is the decimal value.

1011 0110 broken into place values
Position76543210
Weight1286432168421
Bit10110110
Adds128032160420

128 + 32 + 16 + 4 + 2 = 182. Load sample puts this exact byte in the box, and the Place values panel lights up the same five bits. Click the bit under 64 and the total jumps to 246.

The doubling method, for working in your head

Place values get slow past 16 bits, because you need to know 220 or 227 on sight. The doubling method needs no table at all. Start at 0, read the bits from left to right, and for each bit double your total and add the bit.

  1. 1 0 × 2 + 1 = 1
  2. 0 1 × 2 + 0 = 2
  3. 1 2 × 2 + 1 = 5
  4. 1 5 × 2 + 1 = 11
  5. 0 11 × 2 + 0 = 22
  6. 1 22 × 2 + 1 = 45
  7. 1 45 × 2 + 1 = 91
  8. 0 91 × 2 + 0 = 182

Same answer, 182. Parsers such as C's strtol read digits the same way, multiplying the running result by the base and adding each digit. The Doubling method panel prints one row per bit for any input up to 64 bits long.

When 1011 0110 means −74

A byte carries no label saying whether the bits hold a count or a signed number. The program reading the byte decides. In two's complement, the format nearly every CPU uses for signed integers, the top bit carries a negative weight. For 8 bits that weight is −128 instead of +128.

Read 1011 0110 as signed and you get −128 + 32 + 16 + 4 + 2 = −74. A shortcut lands on the same number: take the unsigned value and subtract 28. 182 − 256 = −74.

The same 8 bits, read two ways
BitsUnsignedTwo's complement
0000 000000
0111 1111127127
1000 0000128−128
1011 0110182−74
1111 1111255−1

Width changes the answer. 1111 read as 4 bits is −1. Padded out to 8 bits as 0000 1111, the same digits give 15. The Auto width treats the bits you typed as the full register. If your value came out of a 16-bit sensor reading, set Width to 16-bit, or a short paste with a leading 1 comes back negative when the device meant a small positive number.

Bits after the binary point

Right of the point, the weights keep halving: 1/2, 1/4, 1/8, 1/16. So 101.101 is 4 + 1 + 0.5 + 0.125 = 5.625.

Every binary fraction ends in decimal. A fraction with k bits after the point has at most k decimal places, so the converter prints the exact value with no rounding. The reverse direction fails. Decimal 0.1 has no finite binary form, which is why 0.1 + 0.2 in JavaScript prints 0.30000000000000004.

Patterns worth knowing on sight

Binary values you meet in code and networking
BinaryDecimalSeen in
111115One hex digit, F
1111 1111255Largest byte value, top of an RGB channel, a full subnet mask octet
1 0000 0000256How many values one byte holds
16 ones65,535Highest TCP or UDP port number
32 ones4,294,967,295Largest unsigned 32-bit integer
53 ones9,007,199,254,740,991Number.MAX_SAFE_INTEGER in JavaScript
64 ones18,446,744,073,709,551,615Largest unsigned 64-bit integer

A run of n ones always equals 2n − 1. Add one more and every bit rolls over into the next power of 2, the same way 999 plus 1 rolls over to 1000.

Why long inputs need BigInt

The earlier version of this page called parseInt(bits, 2). JavaScript stores the result as a 64-bit float, which holds whole numbers exactly only up to 253 − 1. Fifty-four ones should give 18,014,398,509,481,983. parseInt returns 18,014,398,509,481,984, off by one, and the error grows with every extra bit.

The converter now does the arithmetic with BigInt, so a 64-bit register dump or a 256-bit hash prints every digit. When an input passes 53 bits, the note under the result says so. Treat the note as a warning for your own code: a plain Number holding the same value would drift.

Where this converter stops

Binary to decimal questions

Signed values, odd input formats, and the limits of this page.

How do I convert binary to decimal by hand?

Write the powers of 2 under the bits, starting with 1 on the right and doubling as you move left. Add the powers that sit under a 1. For 1101 that is 8 + 4 + 1 = 13. For long numbers, the doubling method is faster: start at 0, and for each bit from left to right, double the total and add the bit.

What is 11111111 in decimal?

255 as an unsigned byte. Read as an 8-bit two's complement value, the same bits are −1. Press the 1111 1111 chip and flip between Unsigned and Two's complement to see both.

Why does my binary number come out negative?

Two's complement mode is on and the top bit is 1. Switch to Unsigned, or set Width to a size larger than the number of bits you typed. With Width at 16-bit, 1011 0110 is padded to 0000 0000 1011 0110 and reads as 182.

Can I paste 0b1010_0101 straight from my code?

Yes. The 0b prefix, underscores and spaces are stripped before conversion, so literals from Python, Java, C# and Rust paste as they are. Commas are rejected on purpose, because a comma in pasted text usually separates two different values.

How are binary fractions like 0.011 handled?

Each bit after the point is worth half the bit before it: 1/2, 1/4, 1/8 and so on. 0.011 is 0.25 + 0.125 = 0.375. The result is exact, since k fractional bits never need more than k decimal places. Fractions work in Unsigned mode only.

What is the largest binary number the page converts?

4,096 bits, which is a decimal number up to 1,234 digits long. The math uses BigInt, so there is no rounding at 2^53 the way parseInt rounds.

Does this page convert decimal to binary?

No. This page reads binary only. The number base converter on Toolexe goes from decimal to binary, and between any two bases from 2 to 36.

Is the number I type sent to a server?

No. Parsing, BigInt math and the working tables all run in your browser. Nothing leaves the page, and a refresh clears the input.