Lesson 28: Binary on the floor
Bits on the floor
- A computer stores everything as bits: 1 or 0.
- Here the floor holds one byte (8 bits): a black card is 1, a blue card is 0.
- The robot reads the cards one by one and works out the number, like a computer reading memory.
Words for this lesson
| Word | Meaning |
|---|---|
| bit | one binary digit: 0 or 1 |
| byte | 8 bits |
| denary | our normal numbers, base 10 |
| hexadecimal | base 16: digits 0–9 and A–F |
Place values
| Card | Worth |
|---|---|
| 1st | 128 |
| 2nd | 64 |
| 3rd | 32 |
| 4th | 16 |
| 5th | 8 |
| 6th | 4 |
| 7th | 2 |
| 8th | 1 |
- 0100 1101 = 64 + 8 + 4 + 1 = 77.
- The robot does not need the table:
value = value * 2 + bitgives the same answer.
In the exam
- 0478/12/F/M/24 Q8(a): (i) convert the denary number 236 into hexadecimal: 236 // 16 = 14 (E) and 236 % 16 = 12 (C), so EC. (ii) One benefit of hexadecimal instead of binary: it is easier for humans to read and remember, shorter to type, and mistakes are easier to spot.
- Each hex digit is 4 bits, so one byte is always two hex digits: 1110 1100 is E C.
Kesulitan 4/5 · 280 koin + bonus kecil pada penyelesaian pertama hari ini
Eight cards lie in a row, 200 mm apart: a black card is a 1 and a blue card is a 0. Together they are one byte, the most significant bit first. Drive to each card, read the bit with the down eye, and build the number: value = value * 2 + bit. Print Denary: and the value, for example Denary: 77.
Klik Jalankan untuk melihat output di sini.
Kesulitan 4/5 · 280 koin + bonus kecil pada penyelesaian pertama hari ini
Programmers often write a byte as two hexadecimal (hex) digits. After reading the byte, print Hex: and the two digits, for example Hex: A7. The first digit is value // 16 and the second is value % 16: find each one in the string digits.
Klik Jalankan untuk melihat output di sini.