StudyVault
Home Unit Overview Exam Technique Revision Techniques ← Previous Lesson Next Lesson →

← Back to Dashboard

Overlay:
0:00 / 0:00 Narration generated using AI text-to-speech.

Data Representation (Binary, Hex & Character Sets)

Why Computers Work in Binary

Deep inside every computer are billions of tiny electronic switches. Each switch can only ever be in one of two states: on or off. Because of this, a computer stores and processes everything — numbers, text, images and sound — using just two digits, 0 and 1. This two-digit system is called binary, or base 2. The numbers you use every day are made from the digits 0 to 9 and belong to a different system called denary, or base 10. To be useful, a computer must be able to move smoothly between the two.

Key Fact

A single binary digit, called a bit, can be 0 or 1. Group eight bits together and you can make 256 different patterns, from 00000000 up to 11111111, which represent the denary values 0 to 255.

Reading and Writing Binary Numbers

An 8-bit binary number has eight columns, and each column has a place value that doubles as you move left: 1, 2, 4, 8, 16, 32, 64 and 128. The far-left column, worth 128, is the most significant bit, because it makes the biggest difference to the value. The far-right column, worth 1, is the least significant bit. To find the denary value of a binary number, you simply add up the place values wherever there is a 1.

Converting the other way, from denary to binary, works by subtraction. Take the denary number 156. The largest place value that fits is 128, so write a 1 in that column and subtract, leaving 28. Next, 64 and 32 are both too big, so write 0 for each. Then 16 fits into 28, leaving 12; 8 fits, leaving 4; 4 fits, leaving 0; and 2 and 1 are not needed. Reading the columns gives 10011100.

Suppose you are given 10011100 and asked for its denary value. Write the place values above the digits: 128, 64, 32, 16, 8, 4, 2, 1. Wherever there is a 1, add that place value. Here the 1s sit under 128, 16, 8 and 4, so the total is 128 + 16 + 8 + 4 = 156. Adding the columns that hold a 1 is all there is to it.

Units of Data

The smallest unit of data is a single bit, one 0 or 1. Four bits together make a nibble, and eight bits make a byte. A byte matters because it is just enough to store one character of text. Larger amounts of storage are measured by multiplying up in steps of one thousand.

A kilobyte (KB) is 1,000 bytes, a megabyte (MB) is 1,000 kilobytes, a gigabyte (GB) is 1,000 megabytes, a terabyte (TB) is 1,000 gigabytes, and a petabyte (PB) is 1,000 terabytes. Each step up multiplies the amount of storage by a thousand, so a one terabyte hard drive holds roughly a trillion bytes of data.

Key Fact

The units of data storage, from smallest to largest, are: bit, nibble, byte, kilobyte, megabyte, gigabyte, terabyte and petabyte. Some devices use 1,024 rather than 1,000 for each step, and either figure is accepted.

Adding Binary Numbers

Computers add binary using four simple rules: 0 + 0 = 0; 0 + 1 = 1; 1 + 1 = 0, carry 1; and 1 + 1 + 1 = 1, carry 1. You work from right to left and carry into the next column, exactly as you do when adding in denary. A problem appears when the answer needs more columns than are available. If two 8-bit numbers add up to more than 255, the result will not fit in 8 bits and the extra carry is lost. This is called an overflow error.

Add 00110101, which is 53, to 00010110, which is 22. Working from the right, a carry is created each time two 1s meet, and the final answer is 01001011. Checking in denary, 53 + 22 = 75, and 01001011 really is 64 + 8 + 2 + 1 = 75.

Now try 11111111 + 00000001. In denary this is 255 + 1 = 256. The answer 100000000 needs nine bits, but only eight are available, so the leading 1 is lost and the byte wrongly reads 00000000. The computer has run out of room, and this overflow makes the stored result incorrect.

Binary Shifts

A binary shift moves every bit a set number of places to the left or right, filling the empty columns with 0s. A shift to the left multiplies the number by two for each place moved, while a shift to the right divides it by two for each place. For example, shifting 00010100, which is 20, two places to the left gives 01010000. Each place doubled the value, so 20 became 20 × 4 = 80, and 01010000 is 64 + 16 = 80. Shift too far and 1s are pushed off the end, where they are lost, which changes the answer.

Hexadecimal

Long strings of 0s and 1s are hard for people to read without slipping up, so programmers often use hexadecimal, or base 16, as a shorthand. Hexadecimal uses sixteen digit symbols: 0 to 9 as normal, then A, B, C, D, E and F standing for the values 10, 11, 12, 13, 14 and 15. It is popular because it is compact and it lines up neatly with binary.

The link is simple: one hexadecimal digit represents exactly one nibble of 4 bits, so a whole byte becomes just two hexadecimal digits. To convert, split a byte into two nibbles and turn each into its hex digit. The byte 10011100 splits into 1001 and 1100, which are 9 and 12, or 9 and C, giving the hexadecimal value 9C. Hexadecimal is widely used for the colour codes on web pages and for memory addresses.

Storing Text: Character Sets

Computers store text by giving every letter, digit and symbol its own binary code. The full list of characters a computer can use, together with their codes, is called a character set. The codes are ordered logically, so the letters follow one another in sequence: if the code for ‘A’ is 65, then ‘B’ is 66 and ‘C’ is 67. This tidy ordering makes it easy to sort text alphabetically and to switch between upper and lower case.

The oldest common character set is ASCII, which uses 7 bits per character and can therefore represent 128 different characters — enough for English letters, digits, punctuation and some control codes. That is not nearly enough for every writing system, so Unicode was created. Unicode uses more bits per character, commonly 16 or 32, letting it represent well over a million characters, including alphabets from around the world and emoji. The rule behind both is the same: a set with n bits per character can represent \(2^n\) different characters, so more bits mean more characters but larger files.

Key Fact

The number of characters a set can hold is found with \(2^n\), where n is the number of bits per character. So 7-bit ASCII holds \(2^7 = 128\) characters and 8 bits hold \(2^8 = 256\). A 200-character message stored in 8-bit codes therefore needs 200 × 8 = 1,600 bits, or 200 bytes.

Practice Questions

Test yourself on this lesson. Pick a question, write your answer, then get it marked.

AI feedback
AI feedback is guidance, not a final exam mark. If you disagree, your teacher's view is always the tie-breaker.
← Back to unit
Video

© 2026 StudyVault · About · FAQ · Copyright & IP · Privacy · Disclaimers

StudyVault Education Ltd · registered in England and Wales, company no. 17490559 · 71–75 Shelton Street, London WC2H 9JQ