DevCalcsBrowse Tools

Binary to Decimal Converter

Convert binary to decimal with a place-value breakdown, two's complement signed values, and fractional binary support

By Waqar Mushtaq · Last updated:

0s and 1s only. Spaces or underscores between groups are fine; a binary point and leading minus sign are allowed.

This converter turns a binary number into its decimal value and shows exactly where that value comes from: every bit, its power of two, and what it contributes to the total. It handles binary fractions (1101.101 = 13.625), arbitrarily long inputs without losing precision, and -- because the same bits can mean different numbers depending on how they're stored -- it also reads a raw bit pattern as unsigned, two's complement, and sign-magnitude at the width you typed and at the standard 8, 16, 32, and 64-bit widths. That's the difference between 11111111 meaning 255 and meaning −1.

How Binary to Decimal Conversion Works

O(n) in the number of bits
N=∑ibi×2iN = \sum_{i} b_i \times 2^{i}

b_i = bit (0 or 1) at position i · positions count up from 0 at the right of the binary point, and down from −1 after it

Ntwo’s complement=−bn−1⋅2n−1+∑i=0n−2bi⋅2iN_{\text{two's complement}} = -b_{n-1} \cdot 2^{n-1} + \sum_{i=0}^{n-2} b_i \cdot 2^{i}

n = bit width -- the most significant bit carries a negative weight

Write the powers of two under each bit, starting from 2⁰ = 1 at the rightmost whole-number bit, and add up the place values wherever the bit is 1.

Example -- 101101: 1×32 + 0×16 + 1×8 + 1×4 + 0×2 + 1×1 = 32 + 8 + 4 + 1 = 45

Example -- a binary fraction, 1101.101: Bits after the binary point are worth ½, ¼, ⅛, and so on. 8 + 4 + 1 + 0.5 + 0.125 = 13.625 Every binary fraction has a finite decimal expansion (because 2 divides 10), so these results are always exact.

Signed numbers. Computers store negative integers in a fixed number of bits, most commonly using two's complement: the leftmost bit is worth −2ⁿ⁻¹ instead of +2ⁿ⁻¹. So the 8-bit pattern 11111111 is −128 + 127 = −1, while 10000000 is −128, the most negative 8-bit value. An equivalent shortcut: if the top bit is 1, subtract 2ⁿ from the unsigned value (255 − 256 = −1). Sign-magnitude, used in some older systems and in floating-point sign bits, simply treats the top bit as a minus sign, so 11111111 is −127 and 10000000 is "negative zero."

The width matters: 11111111 stored in 16 bits is 0000000011111111, whose top bit is 0, so it's 255 under every interpretation. Leading zeros you type are kept when deciding the width.

Use Cases

Reading Register and Memory Dumps

Debuggers and logic analyzers often show raw bits. Reading the same byte as unsigned or two's complement tells you whether 0xFF in a signed char is 255 or −1 -- a classic source of bugs.

Computer Science and Digital Logic Coursework

Check binary-to-decimal and two's complement homework, with the place-value table showing each step of the conversion.

Bit Flags and Permission Masks

Translate a flags register or permission mask into its decimal value, and count how many flags are set.

Fixed-Point Values

Embedded systems often store fractional numbers in fixed-point binary. Entering the bits with the binary point in the right place gives the exact decimal value they represent.

Frequently Asked Questions

How do you convert binary to decimal?

Multiply each bit by its power of two (1, 2, 4, 8, ... from right to left) and add the results. Only the 1 bits contribute, so in practice you add up the place values of the 1s: 1011 = 8 + 2 + 1 = 11.

What is two's complement?

It's the standard way computers represent signed integers. In an n-bit two's complement number, the leftmost bit has a weight of −2ⁿ⁻¹ and the rest are positive powers of two as usual. An 8-bit value ranges from −128 (10000000) to 127 (01111111), and 11111111 is −1.

Why does 11111111 show as both 255 and −1?

The bits are the same; the interpretation differs. As an unsigned 8-bit number it's 255. As an 8-bit two's complement number the top bit means −128, so it's −128 + 127 = −1. The table shows both so you can pick the one that matches how the value is stored.

How are bits after the binary point converted?

They use negative powers of two: the first bit after the point is worth 2⁻¹ = 0.5, the next 2⁻² = 0.25, then 0.125, and so on. So 0.101 = 0.5 + 0.125 = 0.625.

What's the largest binary number this converts?

There's no practical limit -- it uses arbitrary-precision integers, so a 64-bit or even 256-bit value converts exactly. The place-value table shows the first 128 bits.

Methodology

The formula above is implemented as a standalone module covered by unit tests, so its worked examples are re-checked on every change to the site. It is verified against the authoritative sources listed below.

Maintained by Waqar Mushtaq. Spotted a result that looks wrong? Report it and it becomes a failing test.

Sources