Nepal SEE Computer Science study materials
Nepal SEE Computer Science study resources

Lab stickers: 8-bit codes, padding and the hexadecimal duplicate

Nepal SEE Computer Science · Put your knowledge to work in context.

All case studies

Lab stickers: 8-bit codes, padding and the hexadecimal duplicate

At Shree Janata Secondary School, Dhading, 26 computers in the lab are being labelled for the SEE practical examination. Each machine gets an 8-bit binary code printed on a sticker, and the same code in hexadecimal is written into the lab register. A student volunteer, Kiran, has already filled in three rows: computer 5 as 00101, computer 19 as 10011 and computer 26 as 11010. In the hex column he wrote A for computer 10 and 10 for computer 16.

The lab teacher wants every binary code padded to exactly eight bits, because the sticker printer jams on any string longer than eight characters. She also suspects a duplicate: she says computer 10 and computer 16 cannot both carry the same hex address, but Kiran insists his register is correct. Kiran must also explain to a visiting parent why the machine stores numbers in binary at all, and why the lab stopped at 255 when numbering machines.

1. Correct the three binary codes to exactly eight bits, settle whether the hex column really contains a duplicate, and give the correct hexadecimal code for computers 10, 16 and 26. Show each step.

Read the worked answer

Padding. Left-padding with zeros changes nothing about the value: 5 = 4+1 = 101 → 00000101; 19 = 16+2+1 = 10011 → 00010011; 26 = 16+8+2 = 11010 → 00011010.

Hex conversion. Split the 8 bits into two 4-bit groups from the right and convert each group:

  • computer 10 → 0000 1010 → 0A
  • computer 16 → 0001 0000 → 10
  • computer 26 → 0001 1010 → 1A

The duplicate. Kiran copied the decimal number 10 straight into the hex column. Hex 10 has the value sixteen, so only computer 16 can carry it - and that entry is correct. Computer 10 must be 0A. Write hex as two digits always, because 8 bits is exactly two hex digits; once corrected, no two machines share a code.

Exam skill being tested. The mistake is not arithmetic, it is failing to check whether the base changed the meaning of the digits you wrote down.

2. The teacher wants to know why the lab stopped at 255, and whether a 300th computer can be labelled with the same 8-bit stickers.

Read the worked answer

Eight bits give 2^8 = 256 distinct patterns, holding values 00000000 to 11111111, i.e. 0 to 255. So the largest machine number an 8-bit sticker can carry is 255, and 300 is impossible with this scheme.

Options, in order of practicality:

  1. Nine bits - 2^9 = 512, enough for 0 to 511, but the sticker is now nine characters and the printer jams.
  2. Switch the sticker to hex - a 16-bit code is four hex digits (0000 to FFFF), giving 65,536 values in four characters. This is shorter than the current binary sticker, so the printer problem disappears, and the register entry and the sticker become the same string.
  3. Two fields - one for lab room (1–9) and one for machine number within the room (00–99), which scales without changing bit width at all.

The reasoning to state is that the number of distinct labels is 2^n, not 10^n, and that adding one bit doubles the capacity.

3. A parent asks why the computer cannot simply store the number 19 the way it is written on paper. Explain in three or four sentences, and say why the lab also keeps a hex copy.

Read the worked answer

A computer's memory cells are built to hold one of two states reliably - a capacitor charged or discharged, a voltage high or low, a spot magnetised one way or the other. Ten distinguishable states per cell (for the digits 0–9) would be far more expensive and error-prone, so everything is encoded as patterns of the two states, which is binary. The value 19 is therefore stored as 00010011, which is 16 + 2 + 1.

Hexadecimal is only a shorthand for humans, not a different thing inside the machine: one hex digit is exactly four bits, so eight bits is always two hex digits. 19 becomes 13 in hex, and 10011100 becomes 9C. A person copying eight bits is far more likely to drop one than to copy two hex digits, so the register uses hex while the machine uses the bits. No conversion takes place inside the computer - the sticker and the register entry are the same bit pattern written two ways.