Storing Student Marks in Binary
A teacher wants to store test marks for 40 students in a computer system. Each mark is a whole number from 0 to 100. The teacher proposes storing each mark as an 8-bit binary number and also storing the student's name as text. A colleague points out that 8 bits can hold values from 0 to 255, which is more than needed, and suggests using 7 bits instead to save space. The teacher also wants to calculate the class average and must decide whether to store marks as integers or as text. The file will later be sent over a slow network link.
1. Evaluate the colleague's suggestion to use 7 bits per mark instead of 8 bits.
Read the worked answer
Seven bits can represent 2^7 = 128 values, from 0 to 127, which is enough for marks 0 to 100. So the suggestion is technically valid.
However, the saving is small. 40 students x 1 bit saved = 40 bits = 5 bytes in total, which is negligible even on a slow link. Computers normally handle data in whole bytes, so a 7-bit field would need packing and unpacking, adding complexity and error risk for almost no benefit.
A better decision is to keep 8 bits (one byte) per mark, which is simple, aligned with how computers store data, and leaves room for values such as 0 to 255 if the marking scheme changes. The real space saving would come from compressing the names or sending only summary data, not from trimming one bit per mark.
2. Explain why the marks should be stored as integers rather than as text, and how this affects the average calculation.
Read the worked answer
If marks are stored as text, the characters '8' and '5' for 85 are stored as character codes, not as a number. The computer cannot add them meaningfully; sorting would also be alphabetical, so '100' would come before '85'.
If marks are stored as integers in binary, the computer can add, compare and average them directly. The average is found by adding all marks and dividing by 40, then rounding as required. This is faster, less error-prone, and uses less space than text.
The only reason to use text would be to store things like 'absent' alongside numbers, which would then need special handling in the calculation. For this task, integers are clearly the better choice.