Introduction
The binary number system represents numbers using only two digits, 0 and 1, in contrast to the decimal system's ten digits, 0 through 9. Computers use binary because their electronic circuits are built from transistors that most reliably represent two distinct states, such as low voltage and high voltage, rather than ten distinct voltage levels, making a base-2 system a natural and reliable match for the underlying hardware.
Cricket analogy: An umpire's signal system uses only two clear states, out or not out, rather than ten shades of certainty, because two unambiguous signals are far more reliable to communicate than many; a computer's circuits use binary's two states for the same reliability.
Explanation
Each binary digit is called a bit, and its position in a binary number represents a power of two, just as each position in a decimal number represents a power of ten. Reading from right to left, the positions represent 1, 2, 4, 8, 16, and so on; to convert a binary number to decimal, multiply each bit by its position's power of two and sum the results. For example, the binary number 1011 equals one times eight, plus zero times four, plus one times two, plus one times one, which sums to eleven in decimal.
Cricket analogy: A scoreboard's run tally adds contributions from each scoring shot at its own value, a boundary worth four and a six worth six, summing to the total; converting binary to decimal sums each bit's positional value the same way.
Binary numbers are grouped in computing into units such as a byte, which is eight bits and can represent 256 distinct values from 0 to 255. Larger groupings, such as a 32-bit or 64-bit word, let a computer represent much larger ranges of numbers or address much larger amounts of memory, and programmers often use hexadecimal, base 16, as a more compact shorthand for binary because each hexadecimal digit corresponds exactly to four binary bits, making conversions between the two systems straightforward.
Cricket analogy: A team groups eleven individual players into one fielding unit that functions together on the field, just as eight individual bits group into one byte that functions together as a computing unit.
Example
# Convert decimal to binary in Python
bin(11) # '0b1011'
# Convert binary to decimal in Python
int('1011', 2) # 11
# Convert decimal to hexadecimal
hex(11) # '0xb'Running bin(11) confirms that eleven in decimal is represented as 1011 in binary, matching the manual calculation of one times eight, zero times four, one times two, and one times one. The int('1011', 2) call performs the reverse conversion, parsing a binary string back into its decimal value, and hex(11) shows the same number in hexadecimal as 0xb, illustrating how the same underlying value can be represented in decimal, binary, or hexadecimal depending on which is most convenient for a given task.
Cricket analogy: A match report can list the same total runs as a raw number, as a breakdown by boundaries and singles, or as an over-by-over log, depending on which view is most useful; the same value in decimal, binary, or hexadecimal works the same way.
Key Takeaways
- Binary is a base-2 number system using only the digits 0 and 1.
- Computers use binary because transistors reliably represent two distinct electrical states rather than ten.
- Each bit's position represents a power of two, and converting binary to decimal sums each bit times its positional value.
- A byte is eight bits and can represent 256 distinct values, from 0 to 255.
- Hexadecimal is used as a compact shorthand for binary because each hex digit corresponds to exactly four bits.
Practice what you learned
1. How many digits does the binary number system use?
2. Why do computers use the binary number system?
3. What is the decimal value of the binary number 1011?
4. How many bits make up one byte?
5. Why is hexadecimal often used as shorthand for binary?
Was this page helpful?
You May Also Like
What Is a Motherboard
How the motherboard acts as the central circuit board that connects the CPU, memory, storage, and peripherals into one working computer.
What Is an Operating System
How an operating system manages a computer's hardware and provides the environment in which applications run.
Types of Operating Systems
An overview of major operating system categories, including batch, time-sharing, real-time, distributed, and mobile operating systems.