2.1 Binary numbers: bits and abstractionEverything is ones and zeros

A computer is built from billions of tiny switches, and each switch has only two states: on or off. We write those states as 1 and 0. One of these two-state values is a bit, short for binary digit. Bits are the only thing a computer can store, so everything it handles, numbers, letters, colors, sounds, must be turned into patterns of bits.
A single bit can only say yes or no, so computers group bits together. A group of 8 bits is a byte. The bigger units you know from file sizes are just lots of bytes: a kilobyte is about a thousand bytes, a megabyte about a million, a gigabyte about a billion.
?Wait, what does "abstraction" mean in this course?
Bits are grouped to represent abstractions: numbers, characters, colors and more. And here is the idea the exam loves: the same sequence of bits may represent different types of data in different contexts. The bits themselves carry no meaning. The program reading them decides whether they are a number, a letter, or part of a picture.
?Wait, what's ASCII?
Colors work the same way. A screen pixel usually mixes red, green and blue light, and each of the three gets one byte, a number from 0 to 255. So one pixel takes 24 bits. Pure red is 255, 0, 0. A warm orange is 255, 165, 0. The picture on your screen is millions of these little three-byte recipes.
I thought about it. Show me
- (a) Add the place values where there is a 1: 01001000 has 1s in the 64s place and the 8s place, so 64 + 8 = 72.
Why?
The next section teaches place values in full. Here, the places from the left are 128, 64, 32, 16, 8, 4, 2, 1. - (b) A is 65, B is 66, and so on. 72 is 7 more than 65, so count 7 letters past A: B, C, D, E, F, G, H. It's H.
- (c) The same sequence of bits means different things in different contexts. The program decides how to interpret them.
Why?
This is exactly the sentence the course uses, and it shows up in multiple-choice questions.
Answer: (a) 72. (b) H. (c) The same bits can represent different kinds of data; the meaning comes from the context.
Stuck? Get a hint
- Which places hold a 1? Count from the right: 1, 2, 4, 8, 16, 32, 64, 128.
- The 1s are in the 64 and 8 places.
- For the letter, count up from A = 65 to 72.
- AA given sequence of bits always represents the same number.
- BBits can represent only numbers, so text must be stored separately.
- CThe same sequence of bits can represent a number, a character or a color, depending on how a program interprets it.
- DA byte is 2 bits.
Show the answer
C. Bits have no built-in meaning: context decides whether they are a number, a letter or a pixel. Text is stored as bits too, using a code like ASCII, and a byte is 8 bits.
- A bit is a binary digit, 0 or 1. A byte is 8 bits.
- Bits are grouped to represent abstractions such as numbers, characters and colors.
- The same sequence of bits can mean different things in different contexts.
- A typical pixel uses 24 bits: one byte each for red, green and blue.