Computer Science

Common mistakes in data representation

3 mistakes learners make with data representation, each one named and explained.

All common mistakes

Everything is stored as binary, and the units and place values have fixed sizes.

Binary place values miscounted

What it looks like

A binary number is converted with the columns shifted, giving a power of two out.

Why it happens

The columns double rather than going up in tens, so a slip of one column changes the answer by a factor of two.

A worked example

Question. What is 1010 in denary?

A common answer. 12

The answer. 10

Why. The columns are 8, 4, 2, 1. Ones sit in the 8 and the 2 columns, giving 8 + 2 = 10.

Put the two side by side

Getting a column wrong doubles or halves the answer.
Write the column headings first, then read off.

Always write 8 4 2 1 above the digits before converting.

Bits and bytes, or the size factor, confused

What it looks like

A file size is out by a factor of eight, or kilo is treated as exactly a thousand where the question wants 1024.

Why it happens

The words sound alike and the factors are close enough that a wrong one still looks plausible.

A worked example

Question. How many bits are in 2 bytes?

A common answer. 2

The answer. 16

Why. A byte is 8 bits, so 2 bytes is 16 bits. Bit and byte differ by a factor of eight throughout.

Put the two side by side

Bits are the single ones and zeros.
Bytes are groups of eight of them.

Write the factor of 8 down before calculating.

The wrong data type chosen for the value

What it looks like

A price is stored as an integer, or an identifier that is never calculated with is stored as a number.

Why it happens

Types are chosen by what the value looks like rather than by what will be done with it.

A worked example

Question. Which type suits a price like 4.99?

A common answer. Integer

The answer. Real or float

Why. Integers hold whole numbers only, so 4.99 would lose its pence. A value with a fractional part needs a real type.

Put the two side by side

Integers are for whole counts.
Reals are for values with a fractional part.

Choose the type from what the value must be able to hold and do.

WAJD spots these patterns in your child's answers and names the one behind their wrong answers, instead of just marking them wrong.

More computer science topics