DISKhi.txt72 105 333 bytesTEXTPIXELS12864321684210101010101010101#0#1#2
The byte: eight 0/1 lamps, their place values and the number they makeMemory boxes: one byte each, as a number with its hexadecimal tagScreens: the same bytes read as text, or as pixel coloursThe file hi.txt on the disk: a name plus three bytesThe board in front is one byte: eight lamps, each a bit that is 0 or 1, with the place values that turn the pattern into a number (01000001 is 64 + 1 = 65). Tokens carry bytes into the three memory boxes, from memory to the text screen (65 is A in ASCII; é is the two UTF-8 bytes 195 169), from the picture (one pixel is three bytes: red, green, blue), and from the file hi.txt on the disk. The same three bytes, 72, 105, 33, read as numbers, as the text Hi! and as one dark olive green pixel (#486921). The extension .txt tells programs to read them as text.

Bits and bytes

  1. A bit is the smallest piece of data a computer stores: a 0 or a 1, like a switch that is off or on. Numbers, words, photos and music are all stored as long rows of bits.

Text and pictures

Files

Try it in the Python prompt

;; step 1/10 · Bits: 0 or 1
>>> 0b1, 0b0          # one bit: 1 or 0
(1, 0)
>>> 2 ** 1             # so one bit has 2 patterns
2

Hexadecimal (base 16) writes each byte as exactly two digits from 0-9 and A-F: 65 is 41, 255 is FF. Programmers use it because it is short and maps neatly onto bits (each digit is 4 bits). Some programs count 1 KB as 1,024 bytes. The standard names for powers of 1,024 are the binary prefixes KiB, MiB and GiB: 1 KiB = 1,024 bytes, 1 MiB = 1,048,576 bytes.