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.
| Position | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| Weight | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| Bit | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 |
| Adds | 128 | 0 | 32 | 16 | 0 | 4 | 2 | 0 |
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.
10 × 2 + 1 = 101 × 2 + 0 = 212 × 2 + 1 = 515 × 2 + 1 = 11011 × 2 + 0 = 22122 × 2 + 1 = 45145 × 2 + 1 = 91091 × 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.
| Bits | Unsigned | Two's complement |
|---|---|---|
0000 0000 | 0 | 0 |
0111 1111 | 127 | 127 |
1000 0000 | 128 | −128 |
1011 0110 | 182 | −74 |
1111 1111 | 255 | −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 | Decimal | Seen in |
|---|---|---|
1111 | 15 | One hex digit, F |
1111 1111 | 255 | Largest byte value, top of an RGB channel, a full subnet mask octet |
1 0000 0000 | 256 | How many values one byte holds |
| 16 ones | 65,535 | Highest TCP or UDP port number |
| 32 ones | 4,294,967,295 | Largest unsigned 32-bit integer |
| 53 ones | 9,007,199,254,740,991 | Number.MAX_SAFE_INTEGER in JavaScript |
| 64 ones | 18,446,744,073,709,551,615 | Largest 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
- 4,096 bits per input, 64 after the point. The bit grid draws up to 64 bits before the point and 32 after. Longer inputs still get the full result and the sum.
- Two's complement covers whole numbers only. Signed fixed-point formats such as Q15 are not decoded.
- No IEEE 754 decoding. Paste the 32 bits of a float and you get the integer those bits spell, not 3.14. Float bit layouts need a dedicated float inspector.
- Text in binary reads as one big number.
01001000 01101001comes out as 18,537. The binary to text converter splits it into the letters H and i. - One direction. For decimal to binary, or any base to any other, use the number base converter.