Cambridge O Level Computer Science · Syllabus 2210 · Data Representation
Binary
What is Binary?
Binary is the base 2 number system, using only the digits 0 and 1, in which a computer represents and processes all forms of data because its circuits have two stable states.
This definition is part of the Data Representation chapter in Cambridge O Level Computer Science.
Binary in context
Every form of data a computer handles — a number, a character, a sound, an image — is converted into binary before it can be processed or stored. The conversion is done by an agreed encoding rule: place value for numbers, a character set for text, sampling for sound, pixels and colour depth for images. The binary is then held in fixed-width registers and processed using logic gates. Nothing about the pattern 01000001 tells you whether it means the number 65, the character A, one sample of a sound or one pixel of an image — only the rule you were told to apply does.
A computer represents all forms of data in binary, a number system with only two digits, 0 and 1. The reason is physical: the electronic circuits inside a computer can reliably hold and detect two stable states — for example a higher or a lower voltage — and those two states map directly onto the two binary digits. Data in that form is processed using logic gates and is stored, along with instructions, in registers. Any form of data therefore has to be converted into binary before the computer can process it.
In any number system, a digit's value depends on which column it is in. Reading right to left, each column is worth the base times the column before it. In binary the columns are the powers of two: 1, 2, 4, 8, 16, 32, 64, 128… In hexadecimal they are the powers of sixteen: 1, 16, 256, 4096… Reading a number in any base is then just "multiply each digit by its column value and add the results".
Hexadecimal is used because it is easier for people to understand than binary: it is a much shorter representation of the same bit pattern, and each hexadecimal digit maps to exactly four bits, so converting between the two is quick and needs no arithmetic. A shorter string is quicker to read, quicker to write, quicker to say aloud and far less likely to be copied down wrongly. Hexadecimal is a notation for humans — the machine still stores the same binary.
Binary addition works exactly like denary column addition, but you carry when a column reaches two instead of ten. Align the two numbers so their least significant bits are in the same column, add each column from the right, and carry a 1 into the next column whenever the column total is 2 or 3.
A logical shift moves every bit in a register a fixed number of places left or right. Bits that are shifted off the end of the register are lost, and zeros are shifted in at the opposite end. For a positive binary integer, each place of a left shift multiplies the value by two and each place of a right shift divides it by two — but only for as long as no significant bits fall off the end. A logical shift is not a rotation: the bits that leave do not reappear on the other side.
Two's complement is the standard way of representing negative numbers in binary. In an 8-bit two's-complement number the leftmost column is given the place value −128 instead of +128; every other column keeps its usual positive value. That single change lets one 8-bit pattern represent any integer from −128 to +127. A positive value has a most significant bit of 0; a negative value has a most significant bit of 1.
Text has to be converted to binary before a computer can process it. That conversion is done using a character set: an agreed table that gives every character a unique character code, which is then stored as a binary number. ASCII is one such character set. Unicode is another, and it allows for a far greater range of characters and symbols than ASCII, including different languages and emojis — but it requires more bits per character than ASCII.
Sound reaches a microphone as a continuously varying analogue wave. To store it, the wave is sampled: its amplitude is measured at regular intervals, each measurement is recorded as a binary value, and those values are stored in order. Two settings control the process. The sample rate is the number of samples taken in a second. The sample resolution is the number of bits used per sample. Increasing either one makes the stored recording a more accurate representation of the original wave — and increases the file size.
A bitmap image is a grid of tiny squares called pixels. The colour of each pixel is stored as a binary value, and the whole image is simply that list of values in order. Two settings describe the image. The resolution is the number of pixels in the image — for a rectangular image, width × height. The colour depth is the number of bits used to represent each colour, that is the bits per pixel. Increasing either one increases the quality of the image and increases its file size.
Common mistakes with Binary
- 1. Treating a leading zero as optional. Why it fails A register has a fixed width. In an 8-bit register the value 12 is 00001100, not 1100. Inside a hexadecimal-to-binary conversion, 5 must become 0101, not 101, or every bit after it shifts one place and the whole answer is wrong. Fix Decide the width before you write anything, then pad on the left to fill it.
- 2. Calling every carry an overflow. Why it fails Carries happen inside almost every binary addition and are completely normal. An overflow error is different: the correct answer is too large for the register to hold. Fix Only the carry out of the leftmost column of an 8-bit unsigned addition signals overflow. See section 1.1 F.
- 7. Dividing by 1000. Why it fails This topic uses the binary units. 1 KiB is 1024 bytes, 1 MiB is 1024 KiB. Using 1000 gives an answer that is wrong by roughly 2.4% per step and gains no marks. Fix Write "÷ 1024" in the margin before you begin, and give the answer in the unit named in the question.
- M1. "Binary is used only for numbers." Why it fails It confuses one use of binary with binary itself. Text, sound and images are all stored in binary too — only the encoding rule differs. Correct model Any form of data must be converted to binary to be processed by a computer, because its circuits have two stable states. Exam-safe "All forms of data, including text, sound and images, are converted to binary so that the computer can process them." Test yourselfHideQ. Name three non-numeric forms of data that are stored in binary.A. Text, sound and images.
- M2. "Hexadecimal is a form of compression." Why it fails Compression reduces the number of bits stored. Hexadecimal changes only how the same bits are written for a person to read. Correct model Hexadecimal is a notation. FF and 11111111 are the same eight bits in storage. Exam-safe "Hexadecimal is a shorter way for humans to write binary; it does not change the amount of data stored." Test yourselfHideQ. How many bits does the value FF occupy in memory?A. Eight — the same as 11111111.
- M3. "A shorter hexadecimal string means less underlying data." Why it fails The length of the written string is a property of the notation, not of the storage. One hexadecimal digit always stands for four bits. Correct model A 4-digit hexadecimal value is always 16 bits, however short it looks next to the binary. Exam-safe "Each hexadecimal digit represents four bits, so a shorter written form still describes exactly the same number of bits." Test yourselfHideQ. How many bits does the hexadecimal value A35F represent?A. 4 digits × 4 bits = 16 bits.
- M4. "Any carry means overflow." Why it fails Carries occur inside almost every binary addition and are ordinary arithmetic. Only a carry out of the leftmost column of the register signals a problem. Correct model Overflow means the correct result lies outside the register's range, not that a column overflowed into the next one. Exam-safe "A carry between columns is normal; an overflow error occurs only when the result is outside the range the register can represent." Test yourselfHideQ. 90 + 45 in an 8-bit register produces four carries. Is that an overflow?A. No — the total 135 is not greater than 255, so it fits.
- M10. "ASCII stores the visual shape of a letter." Why it fails A character set stores a code number. The shape comes from a font, which is separate data. Correct model Character → character code → binary. The font is applied only when the character is drawn. Exam-safe "A character set maps each character to a code number which is stored in binary; the shape displayed is determined separately by the font." Test yourselfHideQ. A document's font is changed from one typeface to another. Do the stored character codes change?A. No. Only the shapes drawn on screen change.
- M19. "One KiB contains 1000 bytes." Why it fails The units in this topic are the binary ones. Using 1000 introduces an error of about 2.4% at every step, compounding as you climb. Correct model 1 KiB = 1024 bytes, and every step above the byte is ×1024. Exam-safe "Calculations must use 1024, so 1 KiB is 1024 bytes and 1 MiB is 1024 KiB." Test yourselfHideQ. How many bytes in 1 MiB?A. 1024 × 1024 = 1 048 576.
Examiner tips on Binary
- The shortcut worth knowing. There is no direct route between denary and hexadecimal that is faster than going through binary for small values, but for anything over one byte the repeated-division method is quicker. And hexadecimal and binary convert directly, four bits at a time, with no arithmetic at all — so if you are ever asked for denary to hexadecimal and get stuck, convert to binary first, then group in fours.
Questions students ask about Binary
What is the difference between binary, denary and hexadecimal?
Denary is base 10, the number system people normally use, with column values that are powers of ten. Binary is base 2, using only the digits 0 and 1 with column values that are powers of two — the only form a computer actually stores. Hexadecimal is base 16, using the digits 0 to 9 and the letters A to F, with column values that are powers of sixteen. Each hexadecimal digit represents exactly four binary bits, so it is a much shorter way for people to write the same bit pattern.
Why do computers use binary to represent all forms of data?
A computer represents all data in binary because its electronic circuits can reliably hold and detect only two stable states, such as a higher or a lower voltage, which map directly onto the two binary digits 0 and 1. Data in that form is processed using logic gates and stored, along with instructions, in registers. So any form of data — a number, text, sound or an image — has to be converted into binary before the computer can process it.
Does a logical left shift always double the value of a binary number?
No. A logical left shift multiplies a positive value by two for each place shifted only while no significant bit is lost off the left-hand end of the register. Shifting 10110010 (178) left by one place gives 01100100, which is 100, not 356, because the bit worth 128 was shifted out and lost. Bits shifted off the end are gone; zeros are shifted in behind them, so the doubling rule breaks down once a 1 falls off.
Why must file-size and storage calculations use 1024 rather than 1000?
This topic uses the binary storage units: 1 kibibyte (KiB) is 1024 bytes, 1 mebibyte (MiB) is 1024 KiB, and every unit above the byte is 1024 times the one below it. Using 1000 instead introduces an error of roughly 2.4% at every step, which compounds as the calculation climbs through the units, so an answer that divides by 1000 will not match the expected value and gains no marks. Always divide by 1024 and give the answer in the unit the question names.

