How many values fit in so many bits, why each bit doubles them, the byte and 255, and converting between base 2 and base ten both ways.
Step 1 of 7 · How many values in how many bits
Step 1 of 7
How many values in how many bits
The screen shows a picture of a sunset, and in the computer it is only numbers. Each pixel stores three numbers, one for its red light, one for green and one for blue, and each of those is stored in Bits per channel bits. The number of bits decides how many different levels each channel can take, from off to full.
Each channel is now stored in 3 bits. Predict, and then Look inside will enlarge a patch of the picture, split each pixel into its three lights, and stand a ruler with a tick for every level beside the columns.
Step 2 of 7
Each bit doubles
An extra bit does not add two more values; it doubles them all, because every old pattern appears once with a 0 in the new bit and once with a 1. So the number of values in bits is a power of two:
That is exponential growth: it starts slowly and very soon becomes huge. Predict what happens when the bits double.
Step 3 of 7
By the number of levels
The ruler beside the columns now shows the number of levels at each depth. Change Bits per channel and watch the bands in the sky crowd together as the levels multiply, until to the eye they are gone.
Step 4 of 7
A byte
Eight bits are a byte. It is the size computers measure memory and files in, and in true colour each channel is one byte. A byte has values. What is the largest of them?
Step 5 of 7
Reading a byte
To read a byte, write the eight place values over it, from left to right:
and add the ones with a 1 under them. To keep a long byte readable, it is usually written in two groups of four, like .
Step 6 of 7
Writing a byte
The other way, from base ten to base 2, starts from the largest place. Check whether fits in the number: if it does, write 1 and take it away; if not, write 0. Move to with what is left, and so on down to the 1s place. At the end you should be left with .
Step 7 of 7
How many bits you need
Sometimes the question is the other way round: you have things, and each needs a number of its own. How many bits do you need? Look for the smallest power of 2 that reaches . That is the logarithm in base 2, , rounded up, and it is why it is so useful in computer science: each time doubles, you need just one more bit.
Loading the interactive version…
Loading the interactive version…
Each step sets up the Scene for you, and a control marked “fixed” stays put for that step.
Practice · Predict, then look
Each of a pixel’s three colour channels, red, green and blue, is stored here in 3 bits. How many different levels can one channel take?
Practice · Predict, then look
Each of a pixel’s three colour channels, red, green and blue, is stored here in 3 bits. How many different levels can one channel take?
Practice · Predict, then look
At four bits per channel there are 16 levels. How many will there be when the bits double to 8?
Practice · Predict, then look
At four bits per channel there are 16 levels. How many will there be when the bits double to 8?
Practice · Reach the target
Change Bits per channel so that each channel has exactly 64 levels, and press Check.
Practice · Reach the target
Change Bits per channel so that each channel has exactly 64 levels, and press Check.
Practice · Calculate
In true colour each channel is a byte, 8 bits. What is the largest value such a channel stores, the brightest red?
Practice · Calculate
In true colour each channel is a byte, 8 bits. What is the largest value such a channel stores, the brightest red?
Practice · Calculate
A pixel’s red channel is stored as the byte . What is it in base ten?
Practice · Calculate
A pixel’s red channel is stored as the byte . What is it in base ten?
Practice · Choose
Which byte stores the number ?
Practice · Choose
Which byte stores the number ?
Practice · Calculate
You want to give each of 1000 people a different number of their own. How many bits does each number need, at least?
Practice · Calculate
You want to give each of 1000 people a different number of their own. How many bits does each number need, at least?
Lesson complete. Every practice question here is done.