Level 0 · Module 1
Bits and bytes
See how a computer represents choices, numbers, and text using only two states.
Not completed
By the end, you can
- Explain why binary is useful in physical computers.
- Distinguish a bit from a byte.
- Explain why a bit pattern needs context to have meaning.
Summary
A bit holds one of two states, usually written 0 or 1. Eight bits make a byte. A byte has 256 possible patterns, from 00000000 through 11111111. Those patterns do not explain themselves: an agreed rule tells a computer whether a pattern represents a number, text, color, or something else.
Introduction
Electronic circuits can reliably tell two voltage ranges apart. We label those two states 0 and 1. By combining many of these dependable choices, a computer can represent numbers, text, colors, and instructions.
Explanation
With one bit, there are two possible patterns: 0 and 1. Add a second bit and there are four patterns: 00, 01, 10, and 11. Each added bit doubles the number of possible patterns. A byte has eight bits, so it has 256 patterns. The same byte can represent a number, a letter, or part of an image depending on the encoding—the rule used to interpret it.
Real-world example
A simple image can use bytes for red, green, and blue intensity. The byte 255 means the
strongest value in an eight-bit channel, while 0 means none.
One byte at a glance
Interactive exploration
One byte
Step 1 of 8
Each of the eight positions can be 0 or 1, so there are 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2, or 256, possible byte patterns. For example, 01000001 can mean decimal 65 when a program expects a number, or the letter A when it expects text. The surrounding format tells the program which meaning to use.
Code example
const letterA = 0b01000001;
console.log(letterA); // 65
// A text encoding can interpret the same value as "A".Common mistakes
- Calling every group of eight binary digits a visible character.
- Assuming
0always means false and1always means true; their meaning depends on context. - Forgetting that a byte has 256, not 255, possible patterns because zero is included.
Quiz
Knowledge check
Try it
Choose the context
The pattern 01000001 appears in a file. Name two possible interpretations, then explain what
additional information would tell a program which interpretation to use.
Key takeaways
- Bits have two possible states; bytes contain eight bits.
- More bits create exponentially more distinct patterns.
- Encoding rules determine what a bit pattern means.