The decimal and binary systems represent the same numbers with different sets of digits. Decimal uses ten digits, from 0 to 9; binary uses only 0 and 1. The written form changes, but the quantity does not: decimal 13 and binary 1101 represent the same value.

NIST defines a bit as a binary digit whose value is 0 or 1. An ordered bit string may be interpreted as an unsigned integer, but its meaning always depends on context. Learning base conversion therefore means understanding positional notation rather than memorising a table.

What does the base of a numeral system mean?

The base tells us how many elementary digits are available and determines the positional weights. In base 10, positions have powers of 10: ones, tens, hundreds and so on. In base 2, positions have powers of 2.

From right to left, binary weights are:

2⁰ = 1, 2¹ = 2, 2² = 4, 2³ = 8, 2⁴ = 16, ...

The rightmost digit is the least significant bit, or LSB; the leftmost is the most significant bit, or MSB. The NIST bit-string glossary follows the same convention: the most significant bit appears on the left and the least significant bit on the right.

Complete diagram of decimal-to-binary and binary-to-decimal conversion Repeated division by 2 produces binary digits; in the opposite direction each digit is multiplied by its positional weight.

Binary to decimal: add the positional weights

To convert a binary number to decimal, number positions from 0 starting on the right. Multiply each digit by the corresponding power of 2 and add the results.

For 1001₂:

1 × 2³ + 0 × 2² + 0 × 2¹ + 1 × 2⁰

8 + 0 + 0 + 1 = 9

Therefore 1001₂ = 9₁₀. A zero does not remove a position's weight; it simply means that the weight contributes nothing. The 2¹ position is worth 2, but its digit is zero, so the contribution is 0 × 2 = 0.

Illustrated conversion of binary 1001 to decimal 9 Every 1 includes its positional weight, while every 0 leaves that weight out of the sum.

A fast left-to-right method

An equivalent method avoids writing every power. Read from left to right, doubling the partial result and adding the next digit.

For 1101₂:

  • start with 1;
  • 1 × 2 + 1 = 3;
  • 3 × 2 + 0 = 6;
  • 6 × 2 + 1 = 13.

It works because shifting one position to the left in base 2 multiplies a value by 2, just as shifting left in base 10 multiplies by 10.

Decimal to binary: repeated division by 2

To convert a positive integer from base 10 to base 2, divide repeatedly by 2. At every step, record the integer quotient and the remainder. Since the divisor is 2, the remainder can only be 0 or 1.

Convert 13:

  • 13 ÷ 2 = 6, remainder 1;
  • 6 ÷ 2 = 3, remainder 0;
  • 3 ÷ 2 = 1, remainder 1;
  • 1 ÷ 2 = 0, remainder 1.

Reading the remainders from last to first gives 1101₂.

Why are the remainders read from bottom to top?

This is not an arbitrary classroom rule. Every division satisfies:

n = 2 × quotient + remainder

The first remainder tells us whether the number contains one binary unit, the 2⁰ weight. It is therefore the rightmost digit. Dividing the quotient again discovers the 2¹ digit, then 2², and so on. Digits are found from least significant to most significant, while numbers are written in the opposite direction. That is why the final reading order is reversed.

Explanation of why division-by-two remainders are read from bottom to top The first remainder belongs to 2⁰, the second to 2¹ and so on: the rightmost digits are discovered first.

Proof with the number 9

The divisions produce remainders 1, 0, 0, 1. The first is the coefficient of 2⁰, the second of 2¹, the third of 2² and the fourth of 2³. Writing positions in normal order, from 2³ down to 2⁰, gives 1001₂.

The special case of zero

If the initial number is 0, a usual repeated-division loop does not start. Its binary representation is not an empty string, however: it is 0. Programs must handle this case explicitly or use a loop design that produces at least one digit.

Do leading zeros change the value?

For an unsigned binary integer, leading zeros do not change the value: 101, 0101 and 00000101 all represent 5. They can still matter in fixed-width representations, such as 8, 16 or 32 bits, because they show the allocated width.

A byte is a sequence of eight bits. With eight unsigned bits, the smallest value is 0 and the largest is 255, written 11111111₂.

Does the leftmost bit always indicate the sign?

No. This is a common misconception. In an ordinary school conversion, unless stated otherwise, the number is treated as unsigned. Therefore 1001₂ means 9, not -9. Its first 1 has weight 2³.

The meaning changes only when a signed representation and a precise width have been specified. Modern computers normally use two's complement for signed integers. With four bits:

  • 0101₂ represents +5;
  • 1011₂ represents -5 in two's complement.
Comparison between unsigned binary and signed two's-complement numbers The leftmost bit indicates a negative value only when the signed format and bit width are known.

An important precision about the “sign bit”

For introductory purposes, the leftmost bit of a two's-complement integer is often called the sign bit. This is useful, but it is not merely a separate minus symbol. In an n-bit word, its positional weight is negative, -2ⁿ⁻¹, while the other bits retain positive weights.

For four bits:

1011₂ = -8 + 0 + 2 + 1 = -5

This interpretation is valid only because we declared a four-bit two's-complement signed number. The same bit string interpreted as unsigned is 11. A bit string does not carry its interpretation by itself; format and context are required.

Representable ranges

With n unsigned bits, values range from 0 to 2ⁿ - 1. With n two's-complement bits, values range from -2ⁿ⁻¹ to 2ⁿ⁻¹ - 1.

  • 4-bit unsigned: 0 to 15;
  • 4-bit signed two's complement: -8 to +7;
  • 8-bit unsigned: 0 to 255;
  • 8-bit signed two's complement: -128 to +127.

Checking the result with Python

The manual method explains the mechanism; a programming language can verify it. The official Python documentation defines bin() for producing a binary string and int(text, 2) for interpreting a base-2 string.

bin(13) # '0b1101' int("1101", 2) # 13

The 0b prefix marks binary notation. Be careful with negative values: bin(-5) returns -0b101, a textual minus-sign representation, not a fixed-width two's-complement word. To obtain an 8-bit form, for example, the width must be chosen explicitly and an appropriate mask applied.

Common conversion mistakes

  • Starting with power 1 instead of power 0: the rightmost position is always 2⁰.
  • Reading remainders in discovery order: this reverses the result.
  • Forgetting zero: the answer must be the digit 0.
  • Using decimal weights: binary positions are 1, 2, 4, 8, 16, not 1, 10, 100.
  • Treating every leading 1 as negative: a sign exists only in a declared signed representation.
  • Confusing value and encoding: the same string may have different interpretations.

Frequently asked questions

Why do we divide by 2?

Because the target base is 2. Division by the base separates the quotient from the units of the current position.

Can I convert using powers of 2 only?

Yes. Subtract the largest possible power of 2 and place 1 in every used position. Repeated division is simply a systematic method that is easy to automate.

How can I check a conversion quickly?

Convert the result back to decimal by adding positional weights. If the original number is recovered, the conversion is consistent.

Does this method work for fractions?

The integer part uses division by 2. The fractional part uses repeated multiplication by 2, which is a different procedure and deserves a separate article.

Official sources and further reading