Bits, bytes, and binary
You have probably heard someone say that computers are “all just ones and zeros.”
It can sound like unhelpful trivia, but the idea explains how photographs, music, documents, applications, and videos can all be stored by the same machine.
To understand it, we need to look at the smallest unit of digital information: the bitConcept · lights on your mapbitA single 0 or 1, the smallest unit of digital information. Eight of them make a byte..
What is a bit?
Computer hardware needs reliable ways to distinguish between different states, so a tiny part of a computer might represent information using a high or low electrical voltage, a charged or uncharged location, or one of two magnetic states. The exact physical method depends on the hardware.
To make these possibilities easier to work with, we represent the two states as 0 or 1.
A single 0 or 1 is called a bit, a word that comes from “binary digit.”
One bit can represent only two possibilities, so it might mean yes or no, on or off, true or false, or any other choice between two options.
One bit cannot represent much information by itself, so computers become powerful by combining enormous numbers of bits into larger patterns.
From bits to bytes
A group of eight bits is called a byteConcept · lights on your mapbyteA group of eight bits, giving 256 possible patterns. File sizes are quoted in bytes; a kilobyte is a thousand of them, a megabyte a million..
Because each of the eight bits can be either 0 or 1, one byte has 256 possible patterns. For example: 00000000 · 01000001 · 11111111
Each pattern can be treated as a different number, and software can then use agreements, called encodings or formats, to decide what those numbers represent.
One system might interpret a byte pattern as a number, while another might interpret it as part of a letter, color, sound, or computer instruction.
Writing and representing numbers using only 0 and 1 is called binary.
You do not need to learn how to perform binary calculations. The important idea is that computers represent information using combinations of two basic states.
How can bits represent text?
Computers store text by assigning numbers to characters.
In a widely used early encoding system called ASCII, the number 65 represents an uppercase A, so when software sees the corresponding bit pattern it knows to display the letter A.
But modern computers need to represent far more than the English alphabet. They must support Korean, Arabic, Chinese, emojis, mathematical symbols, and thousands of other characters.
Modern text therefore commonly uses encodings built on a standard called Unicode, most often one named UTF-8. In UTF-8, some characters can be represented using one byte, while others require several bytes.
The exact encoding is less important than the underlying idea. Computers store characters as numbers, and those numbers are represented using bits.
Take the letter A from an email you sent, and zoom down through the agreements.
How can bits represent photographs and sound?
A digital photograph is made of tiny points called pixels, and because each pixel is assigned numbers describing its color and brightness, a photograph, containing many pixels, requires many numbers, and therefore many bytes, to describe.
Digital audio works similarly. A device measures sound repeatedly and records those measurements as numbers, and software later interprets them and uses speakers to recreate the sound.
Video combines a rapidly changing sequence of images with audio, and because it contains so much information, video files can become very large.
Text, photographs, music, and video look completely different to us, but to a computer they are all stored as patterns of bits whose meaning depends on how software interprets them. The difference is interpretation.
What determines a file’s size?
A file’s size tells you approximately how many bytes are needed to store it.
Common units include:
- A kilobyte, or KB, is approximately one thousand bytes.
- A megabyte, or MB, is approximately one million bytes.
- A gigabyte, or GB, is approximately one billion bytes.
- A terabyte, or TB, is approximately one trillion bytes.
A short text document may require only a few kilobytes because text generally needs relatively little information.
A photograph may require several megabytes because it contains millions of pixels, and a high-quality video may require several gigabytes because it contains many images every second, along with sound.
But these sizes can vary substantially, since a photograph’s resolution, a video’s length and quality, and the file format being used all affect its size.
Software can also use compression to describe the same content with fewer bytes. You will encounter compression again later in this module.
Binary and computer instructions
Everything so far has been written in binaryConcept · lights on your mapbinaryThe number system that uses only 0 and 1. The native language of hardware because a physical component can reliably hold two states and not ten., the number system that uses only those two digits. And the CPU does not only work with data represented that way. Its instructions are ultimately represented using bits as well.
At the lowest level, a CPU executes instructions in a form called machine codeRecognition — just know it existsmachine codeThe instructions a CPU actually executes, expressed as raw binary patterns. Almost no one writes it directly anymore; the code engineers write gets translated down to it. Module 3 shows you the humane layer engineers actually work in.. Different binary patterns tell the CPU to perform operations such as moving information, comparing values, or carrying out calculations.
Software engineers usually do not write machine code directly. Instead they write in programming languages that are easier for people to understand, and other software translates those instructions into a form the CPU can execute.
You only need to recognize the term machine code for now. Programming languages and translation will be covered later in the curriculum.
Connecting this lesson to code, data, and infrastructure
In Module 1 you learned about code, data, and infrastructure, and this lesson adds a deeper layer to that model.
Data is represented digitally through patterns of bits.
Code is eventually translated into bit patterns that the CPU can execute.
Infrastructure is the physical machinery that stores, moves, and processes those patterns.
The physical representation is not identical everywhere, since RAM, storage drives, processors, and network cables use different physical methods. But software treats the information as the same underlying sequence of bits.
The mental model to remember
A bit is the smallest unit of digital information and can have one of two values: 0 or 1.
A byte is a group of eight bits and can form 256 different patterns.
Binary is a number system that uses only 0 and 1.
Files, text, photographs, sound, video, and computer instructions can all be represented using patterns of bits. Their meaning comes from the rules software uses to interpret those patterns.
Your 300-page novel manuscript is 800 KB. One phone photo of your cat is 3 MB, nearly four times bigger. Why isn't that absurd?
▼ answer the check to continue ▼