CodeIEB
Theory Notes/🗄️ Topic 4: Data & Information Management, Solution Development/11.4.2
11.4.2Grade 11

Representing Data in a Fixed Number of Bits

A deeper dive into why binary representation matters practically — overflow errors, real number precision, and how bit patterns represent things beyond plain numbers.

Reasons for representing data in binary: computer hardware (CPU registers) works with a fixed word size — a fixed number of bits — which has real consequences for the range of values that can be stored.

Representing integers:

TypeFormula (n bits)Example (8 bits)
Unsigned integer range0 to (2ⁿ − 1)0 to 255
Signed integer range−2ⁿ⁻¹ to (2ⁿ⁻¹ − 1)−128 to 127
Overflow error
Occurs when a calculation produces a result too large (or too small) to fit within the fixed number of bits allocated — the value 'wraps around' or is truncated incorrectly, producing an unexpected/incorrect result.

Example

An 8-bit unsigned integer can hold 0–255. If you calculate 250 + 10 = 260, but only 8 bits are available, the result overflows and wraps to an incorrect value (4, since 260 − 256 = 4) instead of the mathematically correct 260.

Representing real numbers uses a mantissa and exponent (similar to scientific notation): the mantissa stores the significant digits, and the exponent stores the scale/position of the decimal point. This format can also overflow, and introduces accuracy trade-offs:

Rounding
Adjusting a number to the nearest representable value, which can round up or down.
Truncation
Simply cutting off the extra digits without rounding, always resulting in a value equal to or smaller than the original in magnitude.

Possible combinations of a fixed number of bits show up throughout IT:

  • IP addressing — IPv4 uses 32 bits (giving ~4.3 billion addresses), IPv6 uses 128 bits (a vastly larger address space) — see 11.2.1.
  • MAC address — typically represented using hexadecimal digits for compactness.
  • Number of colours a pixel can display and screen resolution — more bits per pixel (colour depth) means more possible colours; e.g. 8 bits per colour channel gives 256 shades.

Shortening techniques: hexadecimal digits are used to represent binary values more compactly (since each hex digit represents exactly 4 bits) — this is why MAC addresses and colour codes (e.g. #FF5733) are written in hex rather than long binary strings.

💡 Exam Tip

Overflow error questions often ask you to calculate the valid range for a given number of bits and then explain what happens when a calculation exceeds it — memorise the two formulas above.