Bits and binary numbers
Eight switches can show 256 different patterns, enough for every number from 0 to 255.
Before reading anything, try the switches below. Press All off. Now turn on only the rightmost switch and read the line under the row: 1. Turn it off and switch on the one to its left: 2. The next one gives 4, and the one after that 8. Keep moving left. By the far end you have met every value a switch in a byte can have, and the last one is worth 128.
Drag to turn. Scroll or pinch to zoom.
Each switch is worth twice the one to its right
What you just saw is the whole idea of binary. In decimal each place is worth ten times the place to its right: ones, tens, hundreds. In binary each place is worth twice as much, so the values run 1, 2, 4, 8, 16, 32, 64, 128. To read a pattern, add the values of the switches that are on. 00100101 has the 32, 4 and 1 switches on, which makes 32 + 4 + 1 = 37. Switch on exactly those three and the sum line should agree. One more rule drops out for free. Only the rightmost switch is worth an odd amount. So a number is even exactly when its last bit is 0.
Why a chip uses two states instead of ten
The switches on the screen stand in for real ones. A computer chip holds billions of tiny electronic switches called transistors, and at any moment each one is either letting current through or blocking it. Engineers write those two states as 1 and 0. One of them is a bit, short for binary digit. The letter you type and the song you play both end up as long rows of bits.
Why not ten states, one for each decimal digit? The voltage on a wire inside a chip is never exact. Heat, neighbouring wires and small differences between transistors push it up and down a little all the time. A circuit that only has to tell high from low can shrug most of that off, because anything above a middle line counts as 1 and anything below counts as 0. Squeeze ten levels into the same range and they sit so close together that a little noise could make one read as its neighbour. Two states also suit a switch. It is either fully on or fully off and never has to hold a careful position in between.
Writing 100 with the switches
Going the other way, from a number to bits, works like paying with the biggest coin that fits. Take 100. 128 is too big. 64 fits, leaving 36. 32 fits, leaving 4. 16 and 8 are both too big for 4. 4 fits, leaving 0. So the 64, 32 and 4 switches are on: 1100100, or 01100100 as a full byte. Pick 100 as the target in the scene and check. Some people prefer a second method. Divide by 2 again and again, write down each remainder, then read the remainders from the bottom up. Both give the same bits.
One more switch doubles the patterns
How many different numbers can eight switches make? Every extra bit doubles the count. One bit gives 2 patterns. Two bits give 4: 00, 01, 10 and 11. Three give 8, and n bits give 2 to the power n. A byte, eight bits, gives 256 patterns, so a byte counts from 0 to 255, and that is also why each of the four numbers in an IPv4 address stops at 255. Need to give 1000 things their own number? 9 bits give only 512. You need 10, which give 1024.
Press +1 a few times starting from 0 and watch the switches. It looks like a car's odometer with only two digits on each wheel. 0, then 1, then the 1s place rolls over and carries into the 2s place: 10. Then 11. Then both roll over at once: 100. With every switch on you have 11111111, which is 255. The real answer to 255 + 1 is 256, and it needs a ninth bit: 100000000. The scene keeps only eight bits, so +1 from 255 shows 0. That is overflow. It comes back in the adder unit.
| Bit | One binary digit: 0 or 1 |
| Byte | 8 bits, 256 patterns |
| Place values | 1, 2, 4, 8, 16, 32, 64, 128 |
| n bits | 2ⁿ patterns |
| 11111111 | 255 |
| Overflow | A result too big for the bits that hold it |
- "10 means ten." Only in decimal. In binary, 10 is one 2 and no 1s, so it means two. When a number could be read either way, write a small 2 after it, as in 10₂, to show which system you mean.
- "More 1s means a bigger number." Position matters more than the count. 01111111 has seven 1s and is 127. 10000000 has a single 1 and is 128. The leftmost switch alone outweighs all seven switches to its right, because 128 = 127 + 1.
- "A byte can hold numbers up to 256." A byte has 256 patterns, but one of them, 00000000, is used for zero. That leaves 255 as the largest. Four bits behave the same way: 16 patterns, largest 15.
- What is 1011 in decimal?
- Write 37 in binary (no leading zeros).
- What is 1100100 in decimal?
- How many different patterns can 8 bits show?
- What is the largest number one byte can hold?
- How many patterns do 4 bits give?
- How many bits do you need to give 1000 things different numbers?
- What comes after 0111 when counting in binary? Use four digits.
- Which of these numbers is odd?
- 10011
- 10010
- 11110
- 100
- How many bits does 255 + 1 = 256 need?
- A bit is 0 or 1; a byte is 8 bits.
- Binary place values double: 1, 2, 4, 8, 16, 32, 64, 128.
- n bits give 2ⁿ patterns; a byte holds 0 to 255.
- Adding 1 to all 1s rolls over and needs one more bit.
Sources for this course (9)
- (checked 2026-10-17; reordered 2026-10-19: standards first, then official documentation, then the teaching model and calculations, history sources last)
- Standards: NIST, "Prefixes for binary multiples" (physics.nist.gov/cuu/Units/binary.html: IEC approved kibi, mebi, gibi in December 1998; 1 B = 8 bit; 1 MiB = 1 048 576 B; 1 MB = 1 000 000 B; 1 GiB = 1 073 741 824 B; historical note: memory makers usually mean 2²⁰ bytes by megabyte, storage makers 1 000 000, and the "1.44 MB" diskette uses a megabyte of 1 024 000 bytes)
- IETF RFC 20 "ASCII format for Network Interchange" (1969, 7-bit codes, A = 65, a = 97, 0 = 48)
- IETF RFC 3629 "UTF-8, a transformation format of ISO 10646" (2003: 1 to 4 octets per character, ASCII unchanged, code points up to U+10FFFF, U+0800 to U+FFFF take three octets, "the first octet of a multi-octet sequence indicates the number of octets", example U+D55C U+AD6D U+C5B4 = ED 95 9C EA B5 AD EC 96 B4)
- Official documentation: MDN Web Docs, "<color>" (hexadecimal colour notation #RRGGBB)
- Intel, "Intel Chips" timeline poster (2012: Intel 4004 of 1971 with 2,300 transistors; 2nd generation Core 2010 with 1.16 billion)
- Claude E. Shannon, "A Symbolic Analysis of Relay and Switching Circuits", Transactions of the AIEE vol. 57 (1938)
- abstract of his MIT master's thesis. Computer History Museum, The Silicon Engine, "1947: Invention of the Point-Contact Transistor" (Bardeen and Brattain, December 1947, germanium)
- John von Neumann, "First Draft of a Report on the EDVAC" (30 June 1945, Moore School, reprinted in IEEE Annals of the History of Computing 15:4, 1993).
Checked: 2026-10-17