Skip to main content

CS Fundamentals: Worked Examples

Work through each trace before reading the explanation. Then solve the transfer task without the page open.

Example 1: Bits need an interpretation​

The pattern 11111111 means 255 as an unsigned eight-bit integer and -1 as an eight-bit two's-complement signed integer. Width and interpretation are part of the representation.

In modular eight-bit arithmetic, adding 1 yields 00000000. A programming language might widen, trap, or impose different overflow rules. Predicting language behavior solely from this bit example is an unjustified step.

Example 2: Text length needs a unit​

The string Aé contains two Unicode code points and occupies three UTF-8 bytes. A two-byte allocation based on visible characters is insufficient.

Byte counts serve byte buffers; code-point counts serve some text operations; grapheme clusters approximate user-perceived characters. Visually identical text can also use different code-point sequences. An interface that says only “length” leaves an important contract undefined.

Transfer and self-check​

A protocol declares a three-byte payload for UTF-8 Aé. Should its receiver read three characters? Check: no; read three bytes, then decode according to the declared encoding.

Evidence to keep​

Save your first attempt, corrected reasoning, and transfer result as checkpoint evidence. A matching final answer without an explanation is insufficient. Continue with the guided lab and use the reading guide to repair a specific gap.