Why binary?
Computers are built from transistors that are either on or off, so they only understand two states: 1 and 0. Every piece of data, numbers, text, images, sound, must be converted into binary (base 2) to be stored or processed.
Bits, nibbles, bytes
- A bit is a single binary digit, 0 or 1.
- A nibble is 4 bits.
- A byte is 8 bits, the standard unit computers use to store one character.
- With n bits you can represent 2^n different values. An 8-bit byte gives 2^8 = 256 values, so unsigned range is 0 to 255.
Denary to binary and back
To convert denary to binary, use the place values 128 64 32 16 8 4 2 1 (for 8 bits) and subtract the biggest value that fits, marking a 1, then 0 for values you skip. To convert binary to denary, add up the place values where there is a 1. Common mistake: writing place values left to right without remembering they halve each time, or miscounting the number of bits.
Binary addition and overflow
Add binary like denary but carry when a column reaches 2 (10 in binary). If the result needs more bits than the register holds, this is overflow, and the extra bit is lost, giving a wrong answer.
Hexadecimal
Hex (base 16) uses digits 0-9 then A-F (A=10 up to F=15). Each hex digit represents exactly 4 bits (one nibble), so a byte is written as two hex digits, e.g. 11110000 = F0. Hex is used to shorten binary for things like MAC addresses and colour codes because it is far easier for humans to read.
Binary shifts
A logical left shift multiplies the value by 2 for each place shifted; a right shift divides by 2 (rounding down), for example 00000011 shifted left once becomes 00000110 (3 becomes 6).
Units of storage
1 kilobyte (KB) = 1000 bytes, 1 megabyte (MB) = 1000 KB, 1 gigabyte (GB) = 1000 MB, 1 terabyte (TB) = 1000 GB (OCR uses the decimal, 1000-based, convention, not 1024).
Common mistakes
- Forgetting leading zeros when writing an 8-bit binary number.
- Mixing up KB (1000 bytes) with the old kibibyte (1024 bytes).
- Confusing hex conversion by not splitting into nibbles first.
- Forgetting overflow can occur in binary addition when the register is full.
How many bits are in a byte?
8 bits.
tap to reveal
How many bits are in a nibble?
4 bits.
tap to reveal
How many different values can 8 bits represent?
256 values (0 to 255), because 2^8 = 256.
tap to reveal
What is the general formula for how many values n bits can represent?
2^n
tap to reveal
What are the 8-bit binary place values?
128, 64, 32, 16, 8, 4, 2, 1.
tap to reveal
What base is hexadecimal?
Base 16.
tap to reveal
What digits does hexadecimal use and what do A to F equal?
0-9 then A-F, where A=10, B=11, C=12, D=13, E=14, F=15.
tap to reveal
How many bits does one hex digit represent?
4 bits (one nibble).
tap to reveal
What is 11110000 in hexadecimal?
F0
tap to reveal
What is binary overflow?
When an addition produces a result with more bits than the register can hold, so the extra bit is lost and the answer is wrong.
tap to reveal
What effect does a logical left shift by one place have on a binary value?
It multiplies the value by 2.
tap to reveal
What effect does a logical right shift by one place have on a binary value?
It divides the value by 2, rounding down.
tap to reveal
Under OCR's convention, how many bytes are in 1 kilobyte?
1000 bytes.
tap to reveal
Why do computers use binary rather than denary?
Because transistors only have two reliable states, on and off, matching 1 and 0.
tap to reveal