Getting Started
At their most fundamental level, computers do not understand words, images, or even numbers as we do. Instead, all digital information is processed and stored using a system of millions of tiny electronic switches that can only be in one of two states: on or off. To work with this physical reality, computer science uses the binary number system—a language of just two symbols, 0 and 1—to represent all data, from a simple text message to a complex video game.
What You Should Be Able to Do
Explain how computers represent all information using only two states (0 and 1).
Convert positive integers between the binary (base-2) and decimal (base-10) number systems.
Calculate the range of numbers that can be represented with a given number of bits.
Describe how the concept of abstraction allows simple binary sequences to represent complex data like text or images.
Key Concepts & Application
The Core Idea
We are used to the decimal (base-10) number system, which uses ten digits (0-9). Each position in a decimal number represents a power of 10. For example, the number 352 is really (3 x 100) + (5 x 10) + (2 x 1).
Computers use the binary (base-2) number system, which uses only two digits: 0 and 1. Each of these digits is called a bit, the smallest unit of data in computing. In binary, each position represents a power of 2. A '1' signifies an "on" state (a value is present), and a '0' signifies an "off" state (no value). A group of 8 bits is called a byte.
Imagine a row of light switches. If a switch is on, we call it a 1. If it's off, we call it a 0. By assigning a value to each switch's position (1, 2, 4, 8, 16, etc.), we can represent any number just by flipping the right combination of switches. This is the core principle of how all digital data is stored.
Logic & Application
The key to working with binary is understanding how to convert between our familiar decimal system and the computer's binary system.
Converting Binary to Decimal
To convert a binary number to decimal, you add up the place values for every position that contains a '1'. The place values start at 1 on the right and double for each position to the left (1, 2, 4, 8, 16, 32, 64, 128, ...).
Example: Convert the binary number 10110101 to decimal.
We can use a table to map the bits to their place values:
| Binary Digit | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 1 |
|---|---|---|---|---|---|---|---|---|
| Place Value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Now, add the place values where the binary digit is a 1:
128 + 32 + 16 + 4 + 1 = 181
So, the binary number 10110101 is equal to the decimal number 181.
Converting Decimal to Binary
To convert a decimal number to binary, you can use a subtraction method. Find the largest power of 2 that is less than or equal to your number, and place a 1 in that position. Then, subtract that value from your number and repeat the process with the remainder until you reach 0.
Example: Convert the decimal number 93 to binary.
The powers of 2 are: ..., 128, 64, 32, 16, 8, 4, 2, 1.
The largest power of 2 less than or equal to 93 is 64.
Place a
1in the 64s position.Subtract: 93 - 64 = 29.
The largest power of 2 less than or equal to the remainder (29) is 16.
Place a
1in the 16s position.Subtract: 29 - 16 = 13.
The largest power of 2 less than or equal to the remainder (13) is 8.
Place a
1in the 8s position.Subtract: 13 - 8 = 5.
The largest power of 2 less than or equal to the remainder (5) is 4.
Place a
1in the 4s position.Subtract: 5 - 4 = 1.
The largest power of 2 less than or equal to the remainder (1) is 1.
Place a
1in the 1s position.Subtract: 1 - 1 = 0.
We did not use the 32s or 2s place, so we put
0s in those positions.
Arranging our 1s and 0s gives us the binary number: 01011101. (For an 8-bit number. It can also be written as 1011101).
Tracing & Analysis
The Power of Bits
The number of bits used determines the total number of unique values that can be represented. Each time we add one bit, we double the number of possible combinations. The formula is 2^n, where n is the number of bits.
| Number of Bits (n) | Calculation | Total Values Representable | Range (as unsigned integers) |
|---|---|---|---|
| 1 | 2^1 | 2 | 0 to 1 |
| 2 | 2^2 | 4 | 0 to 3 |
| 3 | 2^3 | 8 | 0 to 7 |
| 4 | 2^4 | 16 | 0 to 15 |
| 8 (1 Byte) | 2^8 | 256 | 0 to 255 |
This exponential growth is why modern computers, which use 64-bit processors, can work with an enormous range of numbers.
Abstraction in Action
The sequence of bits 01000001 is, at its core, just a series of on/off electrical signals. By itself, it has no meaning. However, through abstraction—a fundamental concept in computer science that involves simplifying complexity by hiding lower-level details—we can assign meaning to this sequence.
Level 1 (Lowest): A sequence of 8 bits:
01000001.Level 2 (Number System): We can interpret this as a binary number, which converts to the decimal number 65.
Level 3 (Character Encoding): We can agree on a standard (like ASCII) where the number 65 represents the uppercase letter 'A'.
Level 4 (Highest): The letter 'A' can be part of a word, which is part of a document.
The user only interacts with the letter 'A', unaware of the binary representation underneath. This layering of meaning is a powerful example of abstraction.
Core Concepts & Terminology
Bit: The smallest unit of data in a computer, representing a single binary value of either 0 or 1.
Byte: A sequence of 8 bits. Bytes are the standard unit for measuring digital storage (e.g., kilobytes, megabytes).
Binary (Base-2): A number system that uses only two digits, 0 and 1. It is the fundamental system for representing data in digital computing.
Decimal (Base-10): The standard number system used by humans, which uses ten digits from 0 to 9.
Abstraction: The process of simplifying complex systems by managing complexity and hiding unnecessary details from the user. In this context, it allows us to see binary data as numbers, text, or images rather than just 0s and 1s.
Representable Values: The total number of unique values that can be represented with a fixed number of bits is calculated with the formula 2^n, where
nis the number of bits.
Core Skill Check
Logic Tracing: What is the decimal representation of the binary number
10011?Debugging: A student converted the decimal number 20 to binary as
1010. Identify the logic error in their conversion.Application: How many unique colors can be represented if a computer uses 24 bits to store the color data for a single pixel?
Common Misconceptions & Clarifications
Confusing Binary with Code: Binary is a number system, not a programming language. Programmers write code in languages like Python or Java, which a compiler then translates into binary instructions the computer can execute.
Assuming
10is always "ten": The value of a number depends on its base. The sequence10in binary (base-2) is equal to 2 in decimal (base-10).Thinking Bits are Infinite: Every piece of data is stored using a finite, fixed number of bits. This limitation means there is a maximum value that can be represented, which can sometimes lead to overflow errors if a calculation exceeds this limit.
Believing Conversion Requires Memorization: You do not need to memorize a large binary-to-decimal chart. You only need to understand the process of using powers of 2 to convert between the two systems.
Summary
All information processed by a computer is ultimately represented in binary, a system of 0s and 1s. Each 0 or 1 is a bit, the smallest piece of data, and 8 bits form a byte. Understanding how to convert between our familiar decimal (base-10) system and the computer's binary (base-2) system is a foundational skill in computer science. The number of bits used determines the range of values that can be stored, with n bits allowing for 2^n unique values. Through the powerful concept of abstraction, these simple binary sequences are layered with meaning to represent complex data like numbers, text, images, and sound, forming the bedrock of all digital technology.