XMAKYNA Blog

EngineeringFoundations

How computers turn 0s and 1s into words and pictures

Language: English
Dark schematic of an integrated circuit representing binary information and the path from zeros and ones to meaningful output.

Type a capital X into a blank document. It appears on the screen at once. You recognise a letter, perhaps the beginning of a word. But the keyboard has not sent a tiny drawing of X through the computer. Somewhere between your finger and the display, electrical activity has been turned into information, that information has been interpreted, and the computer has been instructed to draw something you recognise.

In our earlier article, How computers work: Feynman's high-speed filing clerk, we used Richard Feynman's model of a clerk following instructions and reading values from numbered drawers. It explained how a computer can accomplish complicated work through a sequence of simple operations. Now we can look more closely at what those drawers contain and how the electronic machine does something useful with their contents. The answer begins with two symbols: 0 and 1.

A switch can hold one bit

Think of a light switch. For our purposes, it has two positions, off and on. We could label those positions anything, but 0 and 1 are convenient. A choice between two possibilities is one bit, short for binary digit. One bit can distinguish between two states; it cannot, by itself, tell us a person's name or describe a photograph.

Inside a computer, tiny electronic components act as switches. By combining many of these two-state switches, a computer can represent much more than just on or off.

Four bits can count

Imagine placing four switches side by side. Give them the values 8, 4, 2 and 1, reading from left to right. When a switch is on, its value counts; when it is off, it contributes nothing. Set those switches to 0 1 0 1: off, on, off, on. The second switch is worth 4 and the fourth is worth 1. Together, they give us 4 + 1 = 5.

Explore the bitsTap a digit to switch it on or off.
Decimal result5
4 + 1 = 5
Try turning every bit on.
Figure 1. Four binary positions, worth 8, 4, 2 and 1, can represent a number from 0 to 15. The starting pattern 0101 represents 5.

Try a different combination. The pattern 0111 represents 7, and 1111 represents 15. This is binary: a way of writing numbers using only 0 and 1. It follows the same idea as the familiar decimal system, but the place values double as we move left rather than increase tenfold.

Each bit has two possible states, 0 or 1. With four bits, that gives us 2 × 2 × 2 × 2 = 16 possible patterns. Eight bits, commonly grouped into a byte, have 256. We can represent larger numbers by using more bits, without asking the electronics to recognise any additional state. Counting is only the first useful thing we can do with these patterns.

A number can stand for a letter

Return to the letter X on your screen. If we want to store a letter, we need a rule that connects a number with that letter. An early text standard called ASCII supplies a straightforward example: it assigns the number 88 to the capital letter X.

In binary, 88 can be written as 01011000. The leading zero simply pads the seven-bit ASCII code to eight positions. The 1s occupy the positions worth 64, 16 and 8, so their values add up to 88. If a program treats those bits as a number, the value is eighty-eight. If it interprets them according to ASCII, they stand for the character X.

One pattern. Two meanings.Tap any bit, or try a different letter.
As a number88Decimal
As ASCIIXCharacter interpretation

The same bits, interpreted according to ASCII.

Figure 2. The pattern 01011000 represents the number 88 when read as an ordinary binary number, and the character X when read according to ASCII.

Nothing in the pattern resembles the shape of X. The connection comes from the agreed rule for reading it.

Modern computers need to represent many more characters than ASCII can cover, including writing systems from around the world and symbols such as emoji. They use broader standards, notably Unicode, and different ways of encoding characters as bytes. The details vary; the principle remains that stored values acquire meaning through conventions. A word is a sequence of characters represented in this way: a program can store and read the codes for B, O and X in order without needing any special hardware for the word BOX.

The same principle works for colour. One common way to describe a screen pixel is with three numbers indicating the amounts of red, green and blue light. In an ordinary eight-bit-per-channel example, (255, 0, 0) describes red: the red component is at its maximum, while green and blue are at zero. A different convention gives a set of numbers a different interpretation. Text and pictures can therefore be stored using the same basic electrical machinery without being the same kind of information.

We now have an answer to what the filing clerk might find in a drawer: a value that means something because the current task says how to interpret it. But storing a value is not yet doing anything with it. For that, the computer needs instructions.

How the circuitry does the work

Memory holds information that a running program needs, like the drawers in Feynman's model. The central processing unit, or CPU, carries out instructions, performs arithmetic, makes comparisons and helps determine what happens next. In modern computers, the work is spread across many electronic circuits, but the basic idea of retrieving a value, operating on it and recording a result remains useful.

A computer can add numbers using binary. For example, 0101 represents 5, and 0001 represents 1. Add them together and the result is 0110, which represents 6.

Add the bitsChange the two binary numbers, then watch the sum.
First number
5decimal
+
Second number
1decimal
Binary sum
6decimal
5 + 1 = 6 in decimal
Carry behaviourA 1 is carried into the 2s place.
Try 7 + 1, or 15 + 1 for a fifth bit.
Figure 3. Change either four-bit input, add the two binary values and read the result. The sum is always shown in five aligned slots so the extra bit position is ready when needed.

Instructions are represented as 0s and 1s too. Some bits tell the processor what action to perform, while others identify the values to use or where to find them, such as in a register (a small storage space inside the processor). We give these actions short names: MOVE copies a value, ADD adds numbers, COMPARE checks values, and JUMP takes the processor to another instruction. CALL starts a separate set of instructions, and RETURN brings it back afterwards. By following these instructions, sometimes repeating steps or changing direction, the processor carries out a program.

This is where software meets hardware: instructions give the electronic circuits work to do.

Think back to Feynman's filing clerk: the clerk follows instructions to find the right numbered drawer, work with its contents, and sometimes jump to a different step instead of continuing to the next one. The processor follows the same basic idea, carrying out a program through a sequence of simple operations.

The example leaves out a great deal of engineering, including how processors organise their internal working space and how they coordinate their many operations. We do not need those details to understand the essential relationship. The computer stores representations, follows instructions that define what to do with them, and records new representations as results.

How the letter X appears on screen

We can now follow the letter from the beginning. When you press a key, keyboard hardware reports an input to the device. The operating system and application interpret it using such things as the keyboard layout and modifier keys. They decide which character you intended and can store a representation of that character in the document.

When it is time to display the text, the application needs more than the character's numerical code. It also needs to know what the letter should look like. That is one job of a font. Text-rendering software uses the selected font to work out the shape and position of the character, then works out which screen pixels should display which colours. The display produces the light that forms the letter X you see.

Change the font and the letter X may look very different. The character has not changed; the instructions and information used to draw it have. Likewise, the number 88 will not appear as X merely because those bits are stored somewhere. A program must choose to interpret them as text and arrange for that text to be displayed.

This brings together the roles that are easy to confuse. The electrical states let a computer store and manipulate patterns reliably. An encoding tells a program what a pattern represents. Instructions determine how to use it. Finally, the screen turns the result into something visible. The letter on the page is the outcome of that whole process.

Pictures and sound follow the same idea

For a photograph, the input begins with light rather than a key press. A camera sensor measures light reaching many small areas, and the device turns those measurements into digital values. For example, a darker part of the scene can be recorded as a lower number, while a brighter part can be recorded as a higher one. Image-processing software uses the values to construct a picture. The image file may also compress the information so it takes less space; when the picture is displayed, the software interprets its format and supplies the necessary pixel information to the screen.

0 Black128 Grey255 White
Greyscale example. In a conventional eight-bit greyscale image, 0 represents black, 128 grey and 255 white, with other shades in between.

Sound provides another example. A microphone responds to changing air pressure, and electronic circuits turn measurements of that changing signal into digital samples. In a common way of recording sound, values near zero represent small changes in air pressure, while values further above or below zero represent larger changes. Quieter sounds generally produce smaller swings; louder sounds produce larger ones. Software can store, edit or transmit those samples. A speaker at the other end converts electrical signals into new vibrations in the air. The original sound waves have not been folded up and placed in memory. Information describing them has been represented, processed and used to produce sound again.

How sound becomes numbers

Air-pressure measurements over time

Sound-wave example. Each dot marks a measurement. Larger swings above and below zero represent greater changes in air pressure.

These examples involve different measurements, conventions and equipment. Yet each depends on the same underlying capability: the machine can represent information as patterns, operate on those patterns according to instructions, and use physical devices to produce a result. That is enough to connect the two-state circuits inside a chip with text, photographs and music in everyday life.

When things go wrong

The examples we've explored are deliberately simple. Real applications must interpret complicated files, handle unexpected information and make many decisions. To display a photograph, for example, an application must understand the file's contents before it can turn them into a picture. A mistake might produce an incorrect result or cause the application to crash. Sometimes a program attempts to access memory it is not permitted to use, and the computer's hardware and operating system can detect and stop it. But not every mistake triggers such a protection. An application might misuse memory it is allowed to access, or simply make the wrong decision, and continue running without any obvious warning.

Some mistakes can be more serious than a crash. An application might produce incorrect results, lose information or skip a check that should have prevented an action. Think back to Feynman's filing clerk: the clerk can follow an instruction perfectly, but if that instruction points to the wrong drawer, the result may still be wrong. A processor follows instructions without knowing whether they achieve what the programmer intended. When an application handles information from outside incorrectly, such mistakes can sometimes influence decisions or actions in ways that were never intended, potentially creating security problems.

In later articles, we'll explore how these failures arise and how engineers work to prevent them or limit their consequences.

The bottom line

A single bit records one of two possibilities: 0 or 1. With several bits, a computer can represent numbers. With agreed rules for interpreting them, those numbers can stand for characters, colours or measurements of sound. A processor follows instructions to operate on the stored information, while input and output devices connect the electronic system to the world around us.

Think again of the letter X appearing in your document. Its identity comes from a character code; its appearance comes from a font and the software that draws it; its light comes from the display. All of those steps rely on the ability to represent and manipulate information reliably. Understanding that chain is more useful than imagining that a computer somehow contains words and pictures in miniature.