How a computer represents information
A computer works with electrical signals and easily tells two states apart: a signal is present or not (magnetised or not). By agreement one state is taken as 1 and the other as 0, so numbers, text, pictures and sound are all stored as sequences of 0s and 1s. Uniform coding is normally used: with a code of m binary places we can code N = 2^m different characters; for example 2² = 4, 2³ = 8, 2⁸ = 256. For B characters the needed m is found from 2^(m–1) < B ≤ 2^m (for 20 characters m = 5, because 16 < 20 ≤ 32). Letters, digits and signs are coded with the ASCII table, where each character is stored in 1 byte (8 bits): the letter A is 01000001 (65), B is 01000010 (66). The original ASCII has 128 characters (Latin letters, digits, signs); the other 128 places are used by extended tables, for example for Cyrillic letters. So that letters of all languages, such as Uzbek o‘ and g‘, fit one table, the Unicode table is widely used today, but in calculations 1 character = 1 byte. One place of a code is 1 bit, and 8 bits make 1 byte. Larger units: 1 KB (kilobyte) = 1024 bytes, 1 MB = 1024 KB, 1 GB = 1024 MB (the textbook rule; the textbook writes Kb, Mb, while the international standard uses 1 kB = 1000 bytes and writes 1024 bytes as KiB). Byte is written with a capital B and bit with a small b or “bit”: for example, Internet speed is measured in Mbit/s. Transfer speed is the volume transferred in a unit of time: speed = volume : time. On the screen a picture is made of pixels; in a black-and-white picture each pixel takes 1 bit, and with N colours it takes r bits, where N = 2^r (r is the colour depth). On a computer colours are made as mixtures of red, green and blue (RGB). Sound is also turned from analog to digital: the signal is measured many times per second (sampling).
| Places (m) | Characters N = 2^m |
|---|---|
| 1 | 2 |
| 2 | 4 |
| 3 | 8 |
| 4 | 16 |
| 5 | 32 |
| 6 | 64 |
| 7 | 128 |
| 8 | 256 |
1920 × 1080 = 2073600 pixels
2073600 × 24 bit = 49766400 bit = 6220800 bytes ≈ 5.93 MB
(uncompressed; formats such as JPEG are smaller)
A school signal board has 3 flags, each either up or down. They can give 2 · 2 · 2 = 2³ = 8 different signals. Three binary signs can represent 8 different codes.
A signaller sends messages with flags and lamps, an electronics engineer codes device states, and a programmer calculates data size.
On paper write all up-down patterns of three flags with 0 and 1 and make sure none is repeated.
| H | I |
|---|---|
| 72 | 73 |
| 01001000 | 01001001 |
“Binary painter”: a small 8 × 8 picture (a heart) is drawn on squared paper; black = 1, white = 0, and 8 bytes are written. A partner restores the picture from the bytes.