Binary Numbers Explained for Beginners
Binary is not a special computer language — it is ordinary counting with two digits instead of ten. This guide takes you from place value to two’s complement with worked examples you can check yourself.
Counting in any base
Every number system you have ever used works the same way. The digits are worth different amounts depending on where they sit, and the multiplier for each position is a power of the base.
In decimal, the number 4,271 means:
4 x 1000 = 4000 (4 x 10^3)
2 x 100 = 200 (2 x 10^2)
7 x 10 = 70 (7 x 10^1)
1 x 1 = 1 (1 x 10^0)
------
4271Binary is identical except the base is 2, so the positions are worth 1, 2, 4, 8, 16, 32 and so on. The number 1101 means:
1 x 8 = 8 (1 x 2^3)
1 x 4 = 4 (1 x 2^2)
0 x 2 = 0 (0 x 2^1)
1 x 1 = 1 (1 x 2^0)
----
13That is the whole idea. There is nothing more to positional notation than “multiply each digit by its place value and add up”. What makes binary feel unfamiliar is only that you have decades of practice with the base-10 version.
Contrast this with a non-positional system such as Roman numerals, where X always means ten regardless of position. That is precisely why Roman numerals are hopeless for arithmetic and why the Hindu-Arabic system displaced them.
Why computers use two digits
The answer is physics, not mathematics. A computer could in principle work in base 10, and some early machines tried — ENIAC was decimal internally.
The problem is reliability. To represent ten digits electronically you need ten distinguishable voltage levels. If your supply is 5 V, each level is separated by about half a volt, and half a volt of electrical noise — from a nearby switching transistor, a fluctuating supply, or heat — turns a 6 into a 7.
With two levels the margin is enormous: anything below 0.8 V is 0 and anything above 2.0 V is 1. A transistor does not need to be a precise analogue device, only a reliable switch. That tolerance is what allows a modern processor to perform billions of operations per second with essentially zero error rate.
The same two-state logic applies at every layer:
- A transistor conducts or it does not.
- A capacitor in DRAM holds charge or it does not.
- A magnetic domain on a hard disk points one way or the other.
- A pit on an optical disc reflects or scatters.
- A fibre-optic pulse is present or absent.
Claude Shannon proved in 1948 that any information whatsoever — text, images, sound, video — can be represented as a sequence of binary digits without loss. The bit became the universal unit of information, and the practical advantages of two-state electronics did the rest.
Bits, bytes and why eight
A single bit holds one of two values. Group bits together and the number of possible combinations doubles with each one:
| Bits | Combinations | Enough for |
|---|---|---|
| 1 | 2 | Yes or no |
| 2 | 4 | Four directions |
| 4 | 16 | One hexadecimal digit |
| 7 | 128 | The full ASCII set |
| 8 | 256 | One byte; one colour channel |
| 16 | 65,536 | Every character in the Unicode BMP |
| 32 | 4.3 billion | Every IPv4 address |
| 64 | 1.8 x 1019 | Modern memory addressing |
Eight bits became the standard byte with IBM’s System/360 in 1964. It was not inevitable — earlier machines used 6, 7, 9 and 12-bit bytes — but eight won because it comfortably held one character, it was a power of two (making address arithmetic cheap), and it divided neatly into two 4-bit halves that each map to a single hexadecimal digit.
That last property is why hexadecimal is used everywhere binary data is displayed: one byte is always exactly two hex digits, from 00 to FF. See the conversion chart for every value.
Converting by hand
Binary to decimal: add the place values
Write the place values above the digits and add up the ones with a 1 beneath them.
128 64 32 16 8 4 2 1
1 0 1 1 0 1 0 1
128 + 32 + 16 + 4 + 1 = 181Decimal to binary, method 1: subtract the largest power
Find the largest power of two that fits, subtract it, repeat. Faster than division once you know the powers.
181 - 128 = 53 -> bit 128 = 1
53 - 32 = 21 -> bit 64 = 0, bit 32 = 1
21 - 16 = 5 -> bit 16 = 1
5 - 4 = 1 -> bit 8 = 0, bit 4 = 1
1 - 1 = 0 -> bit 2 = 0, bit 1 = 1
Result: 10110101Decimal to binary, method 2: divide by two
Divide repeatedly by 2, recording each remainder, then read the remainders bottom to top.
181 / 2 = 90 r 1
90 / 2 = 45 r 0
45 / 2 = 22 r 1
22 / 2 = 11 r 0
11 / 2 = 5 r 1
5 / 2 = 2 r 1
2 / 2 = 1 r 0
1 / 2 = 0 r 1
Read upwards: 10110101Binary to hex: split into nibbles
Group the bits in fours from the right and convert each group separately. No arithmetic across groups is needed.
1011 0101
B 5 -> 0xB5 -> 181Check any of these with the number system converter, which shows the full working.
Negative numbers and two’s complement
Binary has no minus sign, so a convention is needed. The obvious approach — reserve the top bit as a sign flag — was tried and abandoned, because it gives two representations of zero (+0 and −0) and requires separate circuits for addition and subtraction.
Every modern computer uses two’s complement. To negate a number, invert every bit and add one:
5 = 00000101
invert 11111010
add 1 11111011 = -5This has an elegant consequence: subtraction becomes addition. To compute 12 − 5, add 12 and −5:
00001100 (12)
+ 11111011 (-5)
-----------
100000111 -> discard the 9th bit -> 00000111 = 7One adder circuit handles both operations, there is exactly one zero, and comparison still works. The only oddity is the asymmetric range: eight signed bits cover −128 to +127, because zero occupies one of the “positive” slots. Try it in the bitwise calculator at 8-bit width.
How everything becomes binary
Text is a lookup. Each character has a numeric code point defined by Unicode, and that number is stored in binary. The letter A is 65, which is 01000001. Watch it happen in the text to binary converter.
Images are grids of pixels, each pixel three or four numbers. A pure red pixel is red 255, green 0, blue 0 — 11111111 00000000 00000000. A 1920×1080 uncompressed image is 6.2 million bytes, which is why compression exists.
Sound is a wave sampled thousands of times per second. CD audio measures amplitude 44,100 times per second and stores each measurement as a 16-bit number, giving 65,536 possible levels.
Video is images plus sound plus time, which is why compression matters so much: uncompressed 1080p at 30 fps is about 187 MB per second.
Programs are numbers too. Each machine instruction has a numeric opcode; the processor reads them as binary and executes. There is no fundamental distinction between code and data at the hardware level — which is both the foundation of stored-program computing and the reason buffer overflow attacks work.
Practice problems
Work these out, then check them in the converter.
- Convert
11001to decimal. - Convert 200 to binary.
- What is
1010+0110in binary? - How many bits are needed to represent 1,000 distinct values?
- What is
0xFFin binary and decimal? - Represent −12 in 8-bit two’s complement.
- What ASCII character is
01001010?
Answers
- 25 (16 + 8 + 1)
1100100010000(10 + 6 = 16)- 10 bits — 29 is 512, 210 is 1,024
11111111, decimal 25511110100- J — decimal 74
Frequently Asked Questions
What is binary in simple terms?
A counting system using only 0 and 1, where each position is worth twice the one to its right. Computers use it because electronic components reliably distinguish two states but not ten.
Why do computers use binary instead of decimal?
Reliability. Ten voltage levels would sit half a volt apart and electrical noise would corrupt them. Two levels give a huge margin, which is what makes billions of error-free operations per second possible.
How do you read binary?
Write the place values (1, 2, 4, 8, 16…) above the digits from right to left, then add the values where there is a 1. 1101 is 8 + 4 + 1 = 13.
What is 1 + 1 in binary?
10, which is decimal 2. The column sum exceeds the largest available digit, so you write 0 and carry 1 — exactly as 9 + 1 works in decimal.
How many bits are in a byte?
Eight, giving 256 possible values. It was standardised by IBM's System/360 in 1964; earlier machines used 6, 7, 9 and 12-bit bytes.
Do I need to learn binary to be a programmer?
You can write application code without it, but you will hit a ceiling. Bitwise flags, network protocols, file formats, character encoding and performance work all assume you can think in binary.
What is the largest number in 8 bits?
255 unsigned (all eight bits set), or 127 signed, because one bit is used for the sign in two's complement.
Sources & further reading
- Wikipedia: Binary number — history from Pingala through Leibniz to modern computing
- Shannon, A Mathematical Theory of Communication (1948) — the paper that defined the bit as the unit of information
- Wikipedia: Two's complement — why negative numbers are represented the way they are
- IBM System/360 — the machine that made the 8-bit byte universal