Not sure which lesson to do first? Find your level and get a plan →

CS Thinking · Computational Thinking · Grade 6-8

Binary

Binary is the base-2 number system: every value is written using only 0 and 1, and each digit position counts a power of 2 (1,2,4,8,… reading right to left).

value=∑i=0nbi⋅2i

Quick Answer

Binary is the base-2 number system: every value is written using only 0 and 1, and each digit position counts a power of 2 (1,2,4,8,… reading right to left). Use it to read the numbers a computer stores, or to write a decimal number the way a computer would. To find a value, add the place values that hold a 1: 1101=8+4+1=13. To go the other way, take out the largest power of 2 that fits and repeat with what is left.

Why This 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.

Intuitive Explanation

In decimal, each place is worth 10 times the place to its right: ones, tens, hundreds. Binary works the same way with 2 instead of 10, so the places are worth 1, 2, 4, 8, 16, 32 from the right. Each place holds only 0 or 1, so each place value is either counted once or not at all. Binary 10110 has 1s in the 16, 4 and 2 places, so it is 16 + 4 + 2 = 22.

Counting shows how carrying works. In decimal, 9 + 1 runs out of digits and carries: 10. Binary runs out after 1, so 1 + 1 = 10, read 'one zero' and meaning two. Counting up goes 0, 1, 10, 11, 100, 101, 110, 111, 1000. A new place appears exactly when the count reaches the next power of 2: four is 100 and eight is 1000.

To turn 13 into binary, take out the biggest place value that fits: 8, leaving 5. Then 4 fits, leaving 1. The 2 does not fit; the 1 does. That puts 1s in the 8, 4 and 1 places and a 0 in the 2 place: 1101.

A string of 0s and 1s is not always a binary number. Four yes/no survey answers written 1, 0, 1, 1 are four separate answers, not the number eleven, and 1010 written in decimal means one thousand and ten. You need the context (base 2, a 0b prefix, a value in computer memory) before you add up powers of 2.

Think of it like this. 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.

Core idea. Computers use binary because electronic switches have exactly two states: on (1) or off (0).


When to Use

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.

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

How to Recognize It

Before using binary, check whether the 0s and 1s stand for a number written with place values that are powers of 2.

  1. Is a number written using only the digits 0 and 1, perhaps marked base 2 or 0b?

    Yes means read it as binary, with place values 1, 2, 4, 8 from the right. Without that mark, 101 could also be the ordinary number one hundred and one.

  2. Are you asked for the value of the digits, rather than how many digits there are?

    Yes is binary. If the question is how many values fit in a number of digits, or how much space they take, that is Bits and Bytes.

  3. Do the 0s and 1s stand for a letter, a colour or a sound rather than a number?

    Yes points to Data Representation: the bits form a code, and you need the code's rule, not just place values.

  4. Is each 0 or 1 a separate yes-or-no answer, like true and false?

    Yes points to Boolean values. Binary treats a whole row of 0s and 1s as one number with place values.

Binary vs Bits and Bytes vs Data Representation vs Boolean

All four live in the world of 0 and 1, so they look the same on paper. Ask whether you are finding the number the digits make, counting how much space they take, decoding what they stand for, or reading one true-or-false value.

Binary

Meaning
Binary is the base-2 way of writing numbers, where each place is worth a power of 2.
Key test
The 0s and 1s add up to one number.
Formula
value=∑ibi⋅2i
Example
Binary 1001 is 8 + 1 = 9.

Bits and Bytes

Meaning
Bits and bytes measure how much digital data there is, with 8 bits in every byte.
Key test
Asks how many values fit or how much space is used.
Formula
patterns=2bits
Example
A byte has 8 bits, so it can hold 256 different patterns.

Data Representation

Meaning
Data representation is the set of rules for storing text, pictures and sound as bits.
Key test
The bits stand for something other than a number.
Formula
E:D→{0,1}∗
Example
In ASCII, the letter 'B' is stored as 66, which is 01000010.

Boolean

Meaning
A Boolean is a value that is either true or false, often stored as 1 or 0.
Key test
One digit, one yes-or-no answer, no place values.
Example
isOn = True for a light that is switched on.

Formula & Notation

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

How to read it: 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.

Worked Examples

Example 1 — Read the place values

Easy

Read the binary number 010110 off its place-value columns and give its value in decimal.
Show the steps and the answer
  1. Write the weights starting from the right end: 1, 2, 4, 8, 16, 32. So the bits 0 1 0 1 1 0 sit under 32, 16, 8, 4, 2, 1.

    The rightmost bit is the ones place, and each column to the left is worth twice as much, the way decimal columns grow by 10.

  2. Pick out the columns holding a 1: the 16, 4 and 2 columns.

    Each bit is 0 or 1, so a column is counted once or not at all.

  3. Add those weights: 16 + 4 + 2 = 22.

    Binary to decimal is just the sum of the weights that are switched on.

  4. Check the leading 0: dropping it leaves 10110, which is still 16 + 4 + 2 = 22.

    A 0 on the far left adds nothing, just as 022 and 22 are the same number in decimal.

Answer: 010110 is 22.

Takeaway: Write the weights from the right, starting at 1, then add the weights that sit over a 1.

Example 2 — Value of a pattern vs number of patterns

Standard

A game stores a player's level in 6 bits. (a) The bits are 101101. What level is that? (b) What is the highest level the game can store, and how many different levels are possible?
Show the steps and the answer
  1. For (a), write the weights 32, 16, 8, 4, 2, 1 over 1 0 1 1 0 1 and add the ones under a 1: 32 + 8 + 4 + 1 = 45.

    Part (a) asks for the value of one pattern, which is a binary-to-decimal conversion.

  2. For the highest level, set every bit to 1: 111111 = 32 + 16 + 8 + 4 + 2 + 1 = 63.

    The largest value turns on every weight, and it is one less than the next weight, 64.

  3. For the number of levels, count patterns: 0 to 63 is 64 values, and 26=64.

    This is a different question: it counts patterns instead of reading one, which is the job of Bits and Bytes.

Answer: (a) Level 45. (b) The highest level is 63, and there are 64 possible levels (0 to 63).

Takeaway: 'What is this pattern worth?' is a binary conversion; 'how many patterns are there?' is counting, 2n for n bits.

Example 3 — Find the mistake: reading from the wrong end

Application

Convert 1011 to decimal. Priya writes: "The first digit is worth 1, the next 2, then 4, then 8, so 1011 = 1 + 0 + 4 + 8 = 13." Find the mistake and correct it.
Show the steps and the answer
  1. Find where Priya started: she gave the leftmost digit the weight 1.

    Place values start at the right, at the ones place, just as the ones digit of 347 is the 7.

  2. Rewrite the weights from the right: the digits 1 0 1 1 sit under 8, 4, 2, 1.

    The rightmost digit is worth 20=1, the next 21=2, and so on leftward.

  3. Add the weights under the 1s: 8 + 2 + 1 = 11.

    The 4 column holds a 0, so it adds nothing.

  4. Check by converting 11 back: 8 fits (3 left), 4 does not, 2 fits (1 left), 1 fits, giving 1011.

    Converting back returns the original digits. Priya's 13 would convert back to 1101, the same digits reversed.

Answer: 1011 = 8 + 2 + 1 = 11, not 13.

Takeaway: Start the weights at the right-hand end. Reading from the left reverses the number.

Where You'll See It

  • Light switches in a row

    Eight light switches that are each on (1) or off (0) can show any number from 0 to 255 by reading them as a binary number, the same way a byte stores a value with 8 bits.

  • Counting on your fingers in binary

    If each finger is a 0 (down) or 1 (up) worth a power of 2, ten fingers can count to 1023 instead of just 10, because each extra digit doubles the range.

  • Pixel on/off in a tiny black-and-white image

    A simple monochrome icon stores each pixel as one bit: 1 for white, 0 for black. The whole picture is just a long string of 0s and 1s the screen reads back.

Common Mistakes

  1. The slip: The leftmost binary digit is worth 20=1.

    Why it's tempting: We read normally from left to right, so the left digit feels like 'the first' and therefore the smallest place.

    Instead: Place values grow from the right: the rightmost bit is 20=1, then 21,22,… to the left. In 1010, the leftmost 1 is worth 8, not 1.

  2. The slip: In binary, 1+1=2.

    Why it's tempting: It's true in our everyday base-10, so it feels universal.

    Instead: Binary only has digits 0 and 1, so 1+1 carries: it equals 10 in binary (which is the value two).

  3. The slip: Adding one more bit adds one more possible value.

    Why it's tempting: Adding a digit seems like a small, additive change.

    Instead: Each extra bit doubles the number of values: n bits represent 2n values, so going from 3 to 4 bits jumps from 8 to 16, not 8 to 9.


Mini Practice

Try these on your own. Tap Reveal when you want to check.

  1. Convert the binary number 1011 into a decimal number.

    Hint: From the right, the place values are 1, 2, 4 and 8.

  2. Convert the decimal number 13 into a binary number.

    Hint: Find the largest power of 2 that fits, subtract, and repeat.

  3. Add the binary numbers 0110 and 0011. Give the answer in binary, then check it in decimal.

    Hint: In binary, 1+1 is written 10, so you carry.

  4. What is the largest number you can write with 5 binary digits? Give it in binary and decimal.

    Hint: Put a 1 in every place.

  5. A question asks how many different values 8 on/off switches can show. Is this converting a binary number, or counting bits?

    Hint: Is there one specific string of 0s and 1s to read?

  6. A student converts 110 by giving the places 1, 2, 4 from left to right, getting 1+2+0=3. Correct it.

    Hint: Which end of a binary number is the ones place?

Want the full set?

50 practice questions for this concept — free to try, every one with a complete worked solution showing the why, not just the answer.

Frequently Asked Questions

Why don't computers just use the ten digits we use?

A circuit that only has to tell on from off is simple, cheap and hard to confuse, even when the voltage wobbles a little. A circuit that had to tell ten different levels apart would make many more mistakes. A few early computers, such as ENIAC in the 1940s, did work in decimal, but binary won because it is so much more reliable.

How do I add two binary numbers?

The same way as column addition, but you carry when a column reaches 2 instead of 10. The rules are 0 + 0 = 0, 0 + 1 = 1, and 1 + 1 = 10, which means write 0 and carry 1. For 011 + 001, the right column gives 0 carry 1, the middle column has 1 + 0 plus the carried 1, giving 0 carry 1 again, and the left column takes the last carry: 100, which is 4.

What is hexadecimal, and why do programmers use it?

Hexadecimal is base 16. It uses the digits 0 to 9 and then the letters A to F for ten to fifteen. Each hex digit stands for exactly four binary digits, so a long binary number becomes short and easy to read: 1111 1111 is FF, which is 255. Web colours are written this way; #FF0000 means full red, no green and no blue.

Learning Path

← Before

No prerequisites
Binary

You are here

No earlier computing concept is needed, only place value from ordinary decimal numbers (ones, tens, hundreds). Binary adds a second number system built on powers of 2, and a way to convert between the two. Next, Bits and Bytes counts how many values a group of binary digits can hold, Data Representation uses bit patterns for text, color and sound, and Data Compression shrinks those patterns.

See Also