Welcome to the World of Binary!
Have you ever wondered how computers, smartphones, and games consoles can play videos, run 3D games, and send messages when inside they are just electronic circuits? The secret lies in a special number system called binary.
In these study notes, you will discover what binary numbers are, why computers rely on them, and how to convert between the numbers we use every day and computer binary code. Don't worry if this seems new or tricky at first — with a few simple steps and a place-value grid, you will master it in no time!
Why Do Computers Use Binary?
Humans count in decimal (also called denary or base-10), which uses the ten digits \(0, 1, 2, 3, 4, 5, 6, 7, 8,\) and \(9\). We most likely invented this because we have ten fingers!
Computers, however, do not have fingers. Inside a computer processor, there are millions of microscopic electronic switches called transistors. These switches can only be in one of two physical electrical states:
• ON: High voltage electricity flowing (represented by the number \(1\))
• OFF: Low or no voltage electricity flowing (represented by the number \(0\))
Because these switches can only be ON or OFF, computers do all their thinking, calculating, and storing using just two digits: \(0\) and \(1\). This two-digit system is called binary (or base-2).
Key Takeaway: Computers use binary because their electronic switches can only ever be in two states: ON (\(1\)) or OFF (\(0\)).
---Bits, Nibbles, and Bytes: The Units of Data
Before we start converting numbers, let's look at the basic units of computer memory:
• Bit: Short for Binary digit. A bit is the single smallest unit of data in computing. It can only be a \(0\) or a \(1\).
• Nibble: A group of \(4\) bits (for example: 0101 or 1111). A nibble can represent numbers from \(0\) up to \(15\).
• Byte: A group of \(8\) bits (for example: 00101101 or 11111111). A byte is the standard unit for representing numbers and characters at Key Stage 3. A single byte can represent numbers from \(0\) up to \(255\).
Memory Trick: Think of a "nibble" as a small bite of data, and a "byte" as a full mouthful of \(8\) bits!
Key Takeaway: \(1\) byte = \(2\) nibbles = \(8\) bits.
---Place Values: Decimal vs Binary
In decimal (denary), place values increase by multiplying by \(10\) as you move from right to left: units (\(10^0 = 1\)), tens (\(10^1 = 10\)), hundreds (\(10^2 = 100\)), thousands (\(10^3 = 1000\)).
In binary, place values increase by multiplying by \(2\) (doubling) as you move from right to left:
The 8-Bit Binary Place-Value Table:
\(128\) (\(2^7\)) | \(64\) (\(2^6\)) | \(32\) (\(2^5\)) | \(16\) (\(2^4\)) | \(8\) (\(2^3\)) | \(4\) (\(2^2\)) | \(2\) (\(2^1\)) | \(1\) (\(2^0\))
Top Tip: Always draw this 8-column header line at the top of your page before answering any conversion question. Start with \(1\) on the far right and double the number each time going left: \(1 \rightarrow 2 \rightarrow 4 \rightarrow 8 \rightarrow 16 \rightarrow 32 \rightarrow 64 \rightarrow 128\).
---Converting Binary to Decimal (Denary)
Converting a binary number into a normal decimal number is easy! Follow these three simple steps:
Step 1: Write out the 8-bit place value grid (\(128, 64, 32, 16, 8, 4, 2, 1\)).
Step 2: Write the binary digits underneath the matching column headings.
Step 3: Add together all the column values that have a \(1\) under them. Ignore the columns that have a \(0\).
Worked Example 1
Convert the binary number 00101101 to decimal:
• Column \(128\): \(0\)
• Column \(64\): \(0\)
• Column \(32\): \(1\) \(\rightarrow\) \(32\)
• Column \(16\): \(0\)
• Column \(8\): \(1\) \(\rightarrow\) \(8\)
• Column \(4\): \(1\) \(\rightarrow\) \(4\)
• Column \(2\): \(0\)
• Column \(1\): \(1\) \(\rightarrow\) \(1\)
Now add the values together:
\(32 + 8 + 4 + 1 = \mathbf{45}\)
So, binary 00101101 in decimal is \(45\).
Worked Example 2
Convert the binary number 10000110 to decimal:
Look for the columns with a \(1\):
• The \(128\) column has a \(1\)
• The \(4\) column has a \(1\)
• The \(2\) column has a \(1\)
Calculation: \(128 + 4 + 2 = \mathbf{134}\)
So, binary 10000110 in decimal is \(134\).
Key Takeaway: If a column has a \(1\), the switch is ON (add that column value). If it has a \(0\), the switch is OFF (ignore that column value).
---Converting Decimal (Denary) to Binary
To turn a decimal number into an 8-bit binary number, we use the subtraction method (working strictly from left to right, from \(128\) down to \(1\)).
The Step-by-Step Subtraction Rule:
For each column from left to right:
1. Can the column value be subtracted from your current number without going below zero? (Is your number \(\ge\) column value?)
2. If YES: put a \(1\) in that column and subtract the column value from your number.
3. If NO: put a \(0\) in that column and keep your number the same.
4. Repeat for all 8 columns until you reach the \(1\) column.
Worked Example: Convert 84 to an 8-bit Binary Byte
We start with our target number: \(84\)
• Is \(84 \ge 128\)? No \(\rightarrow\) write \(0\) (Remainder stays \(84\))
• Is \(84 \ge 64\)? Yes \(\rightarrow\) write \(1\) (Subtract: \(84 - 64 = 20\))
• Is \(20 \ge 32\)? No \(\rightarrow\) write \(0\) (Remainder stays \(20\))
• Is \(20 \ge 16\)? Yes \(\rightarrow\) write \(1\) (Subtract: \(20 - 16 = 4\))
• Is \(4 \ge 8\)? No \(\rightarrow\) write \(0\) (Remainder stays \(4\))
• Is \(4 \ge 4\)? Yes \(\rightarrow\) write \(1\) (Subtract: \(4 - 4 = 0\))
• Is \(0 \ge 2\)? No \(\rightarrow\) write \(0\) (Remainder stays \(0\))
• Is \(0 \ge 1\)? No \(\rightarrow\) write \(0\) (Remainder stays \(0\))
Reading the bits from left to right gives: 01010100.
So, decimal \(84\) converted to 8-bit binary is \(01010100\).
Key Takeaway: Always check every column from left to right. Once your remainder hits \(0\), all remaining columns to the right become \(0\).
---Key Characteristics and Handy Patterns
Here are some useful rules and patterns that will help you check your work quickly:
1. Maximum Values
For any number of bits (\(n\)), the maximum number you can represent is \(2^n - 1\):
• For a 4-bit nibble (\(n = 4\)): The maximum value is \(2^4 - 1 = 16 - 1 = \mathbf{15}\) (binary 1111).
• For an 8-bit byte (\(n = 8\)): The maximum value is \(2^8 - 1 = 256 - 1 = \mathbf{255}\) (binary 11111111).
2. Total Unique States
A set of \(n\) bits can create \(2^n\) unique combinations.
For an 8-bit byte, there are \(2^8 = 256\) total unique combinations (representing all integers from \(0\) to \(255\)).
3. The Quick Odd / Even Check
Look at the very last digit on the far right (the \(1\) column, also called the Least Significant Bit):
• If it ends in \(1\), the decimal number is ODD (e.g., \(00000101 = 4 + 1 = 5\)).
• If it ends in \(0\), the decimal number is EVEN (e.g., \(00000110 = 4 + 2 = 6\)).
Why? Because every other column header (\(128, 64, 32, 16, 8, 4, 2\)) is an even number. The only way to make an odd total is to add the \(1\) at the end!
Common Mistakes to Avoid
• Writing place values backwards: Never write \(1, 2, 4, 8 \dots\) from left to right. The smallest value (\(1\)) must always be on the far right, just like the units column in normal maths!
• Missing leading zeros: If a question asks for an 8-bit binary number or a full byte, make sure you write all \(8\) digits. For example, write decimal \(5\) as 00000101, not just 101.
• Base confusion: Do not read binary 10 as the decimal number "ten". In binary, 10 means one \(2\) and zero \(1\)s, which equals decimal \(2\).
• Adding zeros: Make sure you only add place values that have a \(1\) underneath them. Do not add column values that have a \(0\).
• Subtraction slips: Take your time when subtracting during decimal-to-binary conversions to avoid simple mental arithmetic errors.
Quick Review Summary
• Decimal / Denary (Base-10): Uses digits \(0\) to \(9\); place values are powers of \(10\).
• Binary (Base-2): Uses digits \(0\) and \(1\); place values are powers of \(2\) (\(128, 64, 32, 16, 8, 4, 2, 1\)).
• 1 Bit = single \(0\) or \(1\). 1 Nibble = \(4\) bits. 1 Byte = \(8\) bits.
• To convert Binary to Decimal: Write the grid, line up the digits, and add the column numbers where there is a \(1\).
• To convert Decimal to Binary: Compare with columns from left to right, placing a \(1\) and subtracting if it fits, otherwise writing \(0\).
• Range of an 8-bit byte: Represents \(256\) values, ranging from \(0\) (00000000) to \(255\) (11111111).