Binary Formula

Binary is a base-2 number system that uses only two digits, 0 and 1, to represent all values.

The Formula

value=∑i=0nbi⋅2i

Ask yourself: Are you turning a string of 0s and 1s into an ordinary number, or a number into 0s and 1s?

Quick example

Binary 101=4+0+1=5 in decimal Binary 1111=8+4+2+1=15

Notation

Binary numbers are written as sequences of 0s and 1s, often prefixed with '0b' (e.g., 0b1010=10). Each digit is called a bit, and positions are numbered from right to left starting at 0.

What this formula means

Binary is a base-2 number system that uses only two digits, 0 and 1, to represent all values. Each digit position represents a power of 2, and computers use binary because electronic circuits have exactly two states: on and off.

Picture a balance with one weight each of 1, 2, 4, 8 and 16 grams. Each weight is either on the pan (1) or off it (0), and every whole number of grams from 0 to 31 can be made in exactly one way, just as every number has exactly one binary form. The picture stops at addition: binary sums need the carry rule.

Formal view

A binary number bnbn−1…b1b0 represents the decimal value ∑i=0nbi⋅2i, where each bi∈{0,1}.

Worked examples

Example 1

medium
Convert the decimal number 45 to binary.
Show solution

Answer

1011012

First step

1.
Step 1: 45 ÷ 2 = 22 remainder 1.

See the full worked solution + why-it-works coaching

SetupKey insightWhy it worksCommon pitfallConnection

Free: full solutions on 3 topics a day. No card.

Every topic, every day: the Family plan

Example 2

medium
Convert binary 110102 to decimal.

Example 3

medium
Convert 11112 to decimal and explain why it equals 24−1.

Common mistakes

  • Reading binary digits left-to-right instead of right-to-left when assigning powers of 2
  • Forgetting that position 0 (rightmost) has value 20=1, not 21=2
  • Confusing binary arithmetic carries (1 + 1 = 10 in binary, not 2)

Common mistakes guide

If this formula keeps breaking in real problems, read the most common errors before you practice again.

Why this formula matters

Every number, letter and color in a computer is stored as a pattern of 0s and 1s, because a circuit only has to tell on from off. Reading binary shows you why 8 bits stop at 255, why sizes like 256, 512 and 1024 keep turning up, and why adding 1 to 1111 rolls over to 10000. Reading the place values from the wrong end gives a completely different number.

Frequently asked questions

What is the Binary formula?

Binary is a base-2 number system that uses only two digits, 0 and 1, to represent all values. Each digit position represents a power of 2, and computers use binary because electronic circuits have exactly two states: on and off.

How do you use the Binary formula?

Use binary when a number is written with only 0 and 1 and the context says it is base 2: a 0b prefix, the word binary, or a value inside a computer's memory. You also use it in reverse, when asked how a computer would store a decimal number. If the question is how many values or how much space a group of bits gives, that is Bits and Bytes. If it asks what a pattern of bits stands for (a letter, a color), that is Data Representation.

What do the symbols mean in the Binary formula?

Binary numbers are written as sequences of 0s and 1s, often prefixed with '0b' (e.g., 0b1010=10). Each digit is called a bit, and positions are numbered from right to left starting at 0.

Why is the Binary formula important in CS Thinking?

Every number, letter and color in a computer is stored as a pattern of 0s and 1s, because a circuit only has to tell on from off. Reading binary shows you why 8 bits stop at 255, why sizes like 256, 512 and 1024 keep turning up, and why adding 1 to 1111 rolls over to 10000. Reading the place values from the wrong end gives a completely different number.

What do students get wrong about Binary?

Each position is a power of 2 (1, 2, 4, 8 ...). Reading right-to-left: position 0 = 1, position 1 = 2, etc.