GoalWork out how many bytes and bits a message needs and say why all computers use the same code.
New words
encode · to turn a message into a code, such as bytesdecode · to turn a code back into the messagecharacter · a letter, digit, punctuation mark or spacestorage · the room that a computer has to keep data
Explanation
A message is stored as one byte for every character. Spaces and punctuation marks count as characters, too. To find the size of a message, count its characters. This is the number of bytes. Multiply by 8 to find the number of bits. For example, ‘Hi, Mum!’ has 8 characters: H, i, comma, space, M, u, m and !. That is 8 bytes, or 8 × 8 = 64 bits. Every computer uses the same code table. If they did not, the same pattern could show different letters on different computers, and messages would be spoiled.
Worked examples
‘Hello, Ana!’ has H, e, l, l, o (5), the comma (1), the space (1), A, n, a (3) and the exclamation mark (1). That is 5 + 1 + 1 + 3 + 1 = 11 characters, so 11 bytes and 11 × 8 = 88 bits.
Character
Byte
A
0100 0001
space
0010 0000
B
0100 0010
A space is a character with its own byte. The text ‘A B’ has three characters, so it needs three bytes.
Suppose one computer sent 0100 0001 meaning A, but another computer used a different table and showed that pattern as another letter. The message would arrive spoiled. A shared code makes sure that every computer shows the same letter.
Class activity
Byte counting (pairs). Each partner writes a short sentence, such as a greeting, with a full stop at the end. Swap sentences. Count the characters, including the spaces and the full stop. Write the number of bytes and the number of bits. Check each other’s counts. Whose sentence needs the most bytes? Can you write a sentence of exactly 20 bytes?
Practice
1
How many bytes and how many bits does ‘OK, GO!’ need?
The characters are O, K, comma, space, G, O and ! so there are 7. That is 7 bytes and 7 × 8 = 56 bits.
2
A message is 20 bytes long. How many bits is it?
20 × 8 = 160 bits.
3
Which needs more storage, ‘HELLO’ or ‘HI THERE’? Give the number of bytes for each.
‘HI THERE’ needs more. HELLO has 5 characters, so 5 bytes. HI THERE has 8 characters, including the space, so 8 bytes.
4
Why must all computers use the same code table for letters?
So that a pattern means the same character on every computer. Otherwise a message sent from one computer would show the wrong letters on another.