ViewWiki

Lesson 1 of 4

Bits on switches.

About 20 minutes · 5 practice questions

A switch that is a number: what a bit is, how many patterns two bits make, place value in base 2, and why 10 in base 2 is two.

Step 1 of 5 · One bit

Step 1 of 5

One bit

A computer is built from billions of tiny switches, transistors, and each can be in only one of two states: conducting or not, high voltage or low. The two states are called 00⁠ and 11⁠. A digit like that, with only two values, is a bit, short for binary digit.

The board has two switches, A and B, and each is a bit. The gates and lights after them are the next Unit’s subject; for now, look only at the switches. One bit tells only two things apart: yes and no, on and off. How many things can two bits tell apart?

To the question

Step 2 of 5

Place value

For two switches to hold a number, each place is given a value. In a decimal number like 3737⁠ the 3 is worth thirty, because it is in the tens place. In base 2 each place is worth twice the place to its right: the rightmost is worth 11⁠, the next 22⁠, then 44⁠, 88⁠ and so on.

On the board A is the 2s place and B the 1s place, so the switches are worth

A×2+B×1A \times 2 + B \times 1⁠

Number in the controls is that value in base ten, and the switches show it in base 2. Predict, and then Number will move to 22⁠.

To the question

Step 3 of 5

One one

To keep the bases apart, the base is written as a subscript: 10210_2⁠ is “one zero in base 2”, that is two, and a plain 1010⁠ is ten. Now go the other way: move Number until the switches show 11211_2⁠, and read what it is in base ten.

To the question

Step 4 of 5

More bits

Two bits only reach 33⁠. To hold bigger numbers you add bits on the left, each worth twice the one before. Four bits are the places

84218 \quad 4 \quad 2 \quad 1⁠

To read a binary number, write the place values over the bits and add the ones with a 1 under them. A 0 bit adds nothing, but it holds the place, just like the 0 in 305305⁠.

To the question

Step 5 of 5

The largest number

Each extra bit doubles the number of patterns, because every pattern of the earlier bits comes once with a 0 and once with a 1. So nn⁠ bits give

2n2^n⁠

patterns, and they are the numbers 00⁠ to 2n−12^n - 1⁠. Eight bits are a byte: 28=2562^8 = 256⁠ values. You will meet that number a lot.

To the question

Interactive scene

Loading the interactive version…

Each step sets up the Scene for you, and a control marked “fixed” stays put for that step.

To the experiment

Practice · Calculate

The board has two switches, A and B, and each can be set to 0 or 1. How many different patterns can the two switches make?

To the experiment

Practice · Predict, then look

Number is at 0, and both switches are down. A is the 2s place and B the 1s place. How will the switches stand when the number is 22⁠?

To the experiment

Practice · Reach the target

Move Number until both switches are up, the bits 11, and press Check. Which number is it?

To the experiment

Practice · Calculate

Add two more switches on the left, in the 4s and 8s places. The four switches show 1011. Which decimal number is that?

To the experiment

Practice · Calculate

What is the largest number four bits can hold?