CalcWorldHub
Computer science · CalcWorldHub

Binary to Decimal Conversion: Read a Base-2 Integer

A binary-to-decimal conversion turns a string of zeroes and ones into the integer value represented by those digits. Each position carries a power-of-two weight, starting at one on the right. The result is useful when reading a register, bit field, or classroom example, provided the input is intended as an unsigned base-two numeral.

Open calculator
A binary string is expanded into powers of two and summed to form an unsigned decimal value.

Share this article

Binary digits are assigned powers of two from right to left.
Place values build the integer

Read the bit string as a base-two numeral

Binary is a positional numeral system with base two. Moving one place left doubles the place value: 1, 2, 4, 8, 16, and so on. A bit contributes its place value only when it is one. The written string is therefore a compact representation of an integer, and the same value can be displayed with different leading zeroes when a fixed-width format is used.

Enter the bits without changing width

Enter a sequence containing only binary digits. This calculator’s field is intended for up to 32 bits and returns an unsigned decimal integer. Do not add a “0b” prefix or separators unless the input field specifically accepts them. Leading zeroes may be kept for display width, but they do not change the unsigned value.

Apply positional powers of two

For bits bᵢ indexed from the right starting at zero, the value is Σ bᵢ2ⁱ. For a short word, expand the one-bits into their powers and add them; zero positions contribute nothing. NIST’s technical mathematics reference describes binary as a positional system, and the same place-value rule is the basis of the conversion here.

Distinguish value from representation

The decimal result is a value, not a description of every property of the original field. The string alone does not reveal signedness, scaling, units, byte order across multiple bytes, or whether selected bits are flags. Those meanings come from the protocol or register specification and should be checked before interpreting the integer as a measurement.

Check input limits and edge cases

The zero string converts to zero, and leading zeroes leave the result unchanged. A fixed-width code may still need those zeroes for comparison or transmission, so do not discard them when the downstream task is bitwise. Conversion to an integer is appropriate only when the question is numeric value rather than preserving a code’s full representation.

For a quick manual check, the largest place value is determined by the string width, and the maximum unsigned value for w bits is 2ʷ−1. A width limit is about representable input size, while the displayed decimal value may need more digits than the binary string. When a value comes from a device, preserve the original bits in logs so later readers can distinguish the number from its encoding.

For a signed two’s-complement word, the leftmost place is interpreted with a negative weight rather than as an ordinary positive power of two. For example, the same bit pattern can represent a different number depending on width and signedness. Do not apply an unsigned conversion to signed telemetry, counters with overflow behavior, or packed fields until the format specification confirms how the bits should be interpreted.

Worked examples

The conversion treats each input as an unsigned binary integer, reading the rightmost bit as the 2⁰ place.

Convert a six-bit pattern

Inputs: Binary input = 101101.

Calculation: 101101₂ = 1×32 + 0×16 + 1×8 + 1×4 + 0×2 + 1×1 = 45₁₀.

The unsigned decimal value is 45.

Convert an eight-bit all-ones word

Inputs: Binary input = 11111111.

Calculation: 11111111₂ = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255₁₀.

The eight-bit unsigned value is 255.

The decimal value is the sum of each bit multiplied by its positional power of two.
Unsigned conversion

What unsigned conversion omits

If the input is part of a signed two’s-complement field, the leftmost bit may encode sign and the unsigned interpretation will be different from the signed value. Similarly, endianness affects how multiple bytes are assembled before the binary string is formed. This calculator converts the supplied bit order as written and does not infer either convention.

For values larger than the field limit or formats wider than the runtime’s supported integer behavior, use a big-integer or byte-array conversion method designed for the specification. Do not split a wide field arbitrarily; choose the correct grouping, signedness, and order first. A correct place-value sum can still answer the wrong question if the representation was misidentified.

Sources and further reading

Share this article

Browse all articles · Calculator: Binary to decimal calculator