Computer Science · Ch 2 — Encoding Schemes and Number System
Binary Number System
Binary Number System
Why do computers count in 0s and 1s at all? The answer lies in the hardware. The ICs (Integrated Circuits) inside a computer are made up of a very large number of transistors, which are activated by the electronic signals they receive — low or high.
Two states, two digits
A transistor is therefore always in one of two states, and each state is given a digit:
ON / high → 1
OFF / low → 0
These two digits, 1 and 0, form the binary number system. Because it has only two digits, it is also referred to as the base-2 system.
What binary numbers look like
Any string made purely of 0s and 1s is a valid binary number, including numbers with a fractional part. Examples:
(1001011)2 — a whole binary number
(1011.101)2 — a binary number with a fractional part
(111111.01)2 — another fractional binary number
Binary is for machines, decimal is for humans
A binary number can be mapped to an equivalent decimal number that humans understand easily. This two-way mapping is the bridge between the machine's world and ours: the computer stores and processes everything in binary, and we convert to decimal when we need to read the value. (Section 2.3 develops the conversion procedures in full.)
For reference, the decimal digits 0–9 written in binary are:
| Decimal | Binary | Decimal | Binary |
|---|---|---|---|
| 0 | 0 | 5 | 101 |
| 1 | 1 | 6 | 110 |
| 2 | 10 | 7 | 111 |
| Decimal | Binary |
|---|---|
| 0 | 0 |
| 1 | 1 |
| 2 | 10 |
| 3 | 11 |
| 4 | 100 |
| 5 | 101 |
| 6 | 110 |
| 7 | 111 |