Binary Number System: How Computers Count in 0s and 1s
Every photo you view, every message you send, every game you play — at the lowest level, it's all just 0s and 1s. The binary number system is the language of computers, and understanding it unlocks a deeper appreciation of how digital technology works. This guide explains binary from the ground up: how it works, how to convert between binary and decimal, how binary arithmetic operates, and why computers chose base-2 in the first place.
What Is the Binary Number System?
Binary is a base-2 number system that uses only two digits: 0 and 1. This contrasts with the decimal (base-10) system we use daily, which uses digits 0 through 9.
In decimal, each digit's position represents a power of 10:
- 347 = 3×100 + 4×10 + 7×1 = 3×10² + 4×10¹ + 7×10⁰
In binary, each digit's position represents a power of 2:
- 1011 = 1×8 + 0×4 + 1×2 + 1×1 = 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 11 in decimal
Each binary digit is called a bit (binary digit). Eight bits make a byte, which can represent values from 0 to 255.
Why Do Computers Use Binary?
Computers use binary because their hardware is built from electronic switches (transistors) that have two states:
- OFF = 0 (low voltage)
- ON = 1 (high voltage)
This two-state design is far more reliable than trying to distinguish between 10 voltage levels (for decimal). With just two states, the margin for error is enormous, making billions of operations per second possible with virtually zero mistakes.
Modern CPUs contain billions of transistors, each acting as a tiny switch. Together, they perform complex calculations using only binary logic.
Converting Decimal to Binary
To convert a decimal number to binary, repeatedly divide by 2 and record the remainders:
Convert 42 to binary:
42 ÷ 2 = 21 remainder 0
21 ÷ 2 = 10 remainder 1
10 ÷ 2 = 5 remainder 0
5 ÷ 2 = 2 remainder 1
2 ÷ 2 = 1 remainder 0
1 ÷ 2 = 0 remainder 1
Read remainders bottom-to-top: 101010
So 42 in binary = 101010
Convert numbers between any base instantly:
⚡ Number Base ConverterConverting Binary to Decimal
To convert binary to decimal, multiply each bit by its positional power of 2 and sum:
Convert 110101 to decimal:
1×2⁵ + 1×2⁴ + 0×2³ + 1×2² + 0×2¹ + 1×2⁰
= 32 + 16 + 0 + 4 + 0 + 1
= 53
Binary Arithmetic
Addition
Binary addition follows simple rules:
- 0 + 0 = 0
- 0 + 1 = 1
- 1 + 0 = 1
- 1 + 1 = 10 (0, carry 1)
- 1 + 1 + 1 = 11 (1, carry 1)
1011 (11)
+ 1101 (13)
------
11000 (24)
Subtraction
Binary subtraction uses borrowing, similar to decimal. However, computers typically use a method called two's complement to subtract by adding the negative equivalent.
Multiplication
Binary multiplication is simpler than decimal: multiply by either 0 or 1, then shift and add:
101 (5)
× 11 (3)
-----
101
101
-----
1111 (15)
Perform binary arithmetic operations:
⚡ Binary CalculatorBinary, Hexadecimal, and Octal
Because binary numbers get long quickly, programmers often use more compact notations:
Hexadecimal (Base-16)
Uses digits 0-9 and letters A-F (10-15). Each hex digit represents exactly 4 binary bits:
1010 1111in binary =AFin hex- Hex colors like
#FF5733are actually three bytes: R=255, G=87, B=51
Octal (Base-8)
Uses digits 0-7. Each octal digit represents exactly 3 binary bits. Octal is used in Unix file permissions (like chmod 755).
How Computers Store Data in Binary
Text
Characters are mapped to numbers via encoding standards like ASCII and UTF-8. The letter 'A' is 65 in decimal, or 01000001 in binary.
Images
Each pixel is stored as binary values for red, green, and blue channels (8 bits each, 0-255). A 1920×1080 image has over 6 million pixels, each using 24 bits.
Audio
Sound waves are sampled thousands of times per second, and each sample is stored as a binary number. CD-quality audio uses 16-bit samples at 44,100 Hz.
Integers
Computers store integers in fixed sizes: 8-bit (0-255), 16-bit (0-65,535), 32-bit (0-4.29 billion), or 64-bit. Signed integers use two's complement to represent negative numbers.
Bitwise Operations
Programmers use bitwise operations to manipulate individual bits. These are extremely fast because they map directly to CPU instructions:
- AND (
&): Both bits must be 1 → result is 1 - OR (
|): Either bit is 1 → result is 1 - XOR (
^): Bits differ → result is 1 - NOT (
~): Flips all bits - Left shift (
<<): Multiply by power of 2 - Right shift (
>>): Divide by power of 2
Binary in Everyday Technology
- IP addresses: IPv4 addresses like 192.168.1.1 are four 8-bit binary numbers
- Subnet masks: Network masks like 255.255.255.0 determine which bits identify the network vs the host
- File permissions: Unix chmod permissions use octal notation representing binary permission bits
- Color codes: Hex colors are binary values for RGB channels
- QR codes and barcodes: Encode data as binary patterns of black and white
Fun Binary Facts
- There are only 10 types of people in the world: those who understand binary and those who don't (because 10 in binary = 2 in decimal)
- The word "bit" was coined by Claude Shannon in 1948
- A single byte (8 bits) can represent 256 different values
- Your smartphone processes billions of binary operations every second
- The binary system was formalized by Gottfried Leibniz in 1703, centuries before computers
Conclusion
The binary number system is beautifully simple yet incredibly powerful. With just two digits, computers can represent any number, text, image, video, or sound. Understanding binary gives you insight into how technology works at its most fundamental level — from how colors are encoded to why file sizes are measured in powers of 2. Use our Binary Calculator to practice binary arithmetic, or try the Binary to Text Converter and Number Base Converter to explore conversions between number systems.