Rounding errors — AQA A-Level Computer Science
Rounding errors in AQA A-Level Computer Science occur when real numbers cannot be represented precisely within a finite number of bits in fixed-point or floating-point binary formats. This topic evaluates how representation error arises from recurring binary fractions, measures precision loss via absolute and relative error, and assesses compounding inaccuracies in iterative calculations.
Rounding errors explained
A binary fraction extends positional notation past the binary point using negative powers of two.
Read the full explanation
The bit immediately after the point represents 2⁻¹ (one half), the next 2⁻² (one quarter), then 2⁻³ (one eighth), and so on. For example, 0.101 in binary equals 1×2⁻¹ + 0×2⁻² + 1×2⁻³ = 0.5 + 0.125 = 0.625 in decimal. To convert a decimal fraction to binary, repeatedly multiply the fractional part by 2 and record the integer part of each result: 0.75 × 2 = 1.5 (bit 1), 0.5 × 2 = 1.0 (bit 1), giving 0.11 in binary. The statement asks you to use this positional system for fractional values, which is the foundation for later work on why some decimal fractions cannot be stored exactly.
Your focus
- Use binary fractions.
Which command word is this?
Perform mathematical operations step-by-step to arrive at a numerical result. Working must be shown to secure intermediate method marks.
Rounding errors exam tips
Topic Overview
Rounding errors occur in computer systems because hardware memory allocates a finite number of bits to store real numbers. When numbers with infinite expansions (such as recurring binary fractions) or high precision are cast into fixed-point or floating-point representations, the lowest-order bits must be truncated or rounded, inevitably introducing representation errors.
Understanding these errors is vital for software developers, computational scientists, and financial engineers. Unchecked rounding errors can lead to catastrophic software failures, unstable numerical simulations, or substantial financial discrepancies over repeated calculations.
Key Concepts
- →Representation Error: Inability of binary formats to exactly represent base-10 fractions whose denominators are not powers of two (e.g. 0.1 or 0.2).
- →Absolute Error: The raw magnitude of difference between the actual value and the stored approximate value, given by |V_actual - V_approx|.
- →Relative Error: The proportional error relative to the true magnitude, given by |V_actual - V_approx| / V_actual, often converted to a percentage.
- →Cancellation Error (Loss of Significance): Extreme loss of precision occurring when two nearly equal floating-point numbers are subtracted from one another.
- →Error Accumulation: The compounding growth of rounding errors across repetitive iterative loops or chained numerical operations.
Marking Points
- Assigns place values of 2⁻¹, 2⁻², 2⁻³ and so on to the bits after the binary point
- Converts a binary fraction to decimal by summing each bit multiplied by its negative power of two
- Converts a decimal fraction to binary by repeatedly doubling the fractional part and recording integer parts
- Recognises that a fraction with a denominator that is not a power of two may not terminate in binary
Examiner Tips
- 💡Write out the place values 0.5, 0.25, 0.125 and so on before converting, so each bit is weighted correctly
- 💡When converting decimal to binary, record the integer part of each doubled value and stop when the fractional part is zero
- 💡Check your answer by converting it back to decimal
- 💡When asked to calculate relative error, always divide by the true (actual) value, never by the approximate value.
- 💡Show full workings when converting fractional numbers to binary, labeling place values (0.5, 0.25, 0.125, etc.) so that method marks can be awarded even if an arithmetic error occurs.
Common Mistakes
- Treats the first bit after the point as 2⁻² or as worth one tenth; correct it to 2⁻¹, worth one half
- Reads the digits after the binary point using powers of ten; correct it to powers of two
- Stops the doubling method early or misreads the carry, giving a wrong bit pattern; carry out each doubling step fully
- Believing that increasing the exponent size reduces rounding errors. The exponent only controls dynamic range; the mantissa bit allocation determines precision and rounding error.
- Assuming that floating-point arithmetic is always associative. Because of intermediate rounding, (a + b) + c does not necessarily equal a + (b + c) in computer arithmetic.
Revision Plan
- 1Day 1-3: Master binary fractional conversion mechanics and identify which base-10 fractions recur in base-2.
- 2Day 4-6: Practice calculating absolute and relative errors for both fixed-point and normalised floating-point questions.
- 3Day 7-10: Work through exam questions focusing on error accumulation, catastrophic cancellation, and mitigation strategies.
Exam Question Types
- 📋Calculation questions: Converting a decimal fraction into a specified bit format and calculating absolute and relative error.
- 📋Comparison questions: Evaluating the precision trade-offs between fixed-point and floating-point systems.
- 📋Scenario-based application questions: Analysing how rounding errors affect real-world domains such as rocketry, navigation, or financial banking.
Command Word Expectations (AQA)
Perform mathematical operations step-by-step to arrive at a numerical result. Working must be shown to secure intermediate method marks.
Set out the causes, reasons, or mechanisms of a phenomenon using technical terminology (e.g., explaining why 0.2 cannot be stored exactly in binary).
Identify both similarities and differences between two formats or approaches (e.g., fixed-point vs floating-point) in relation to precision and range.
How Students Lose Marks (Examiner Pitfalls)
Step-by-Step Worked Solutions
Question: A real number with a true value of 6.7 is stored in an 8-bit fixed-point format (4 bits for the integer part and 4 bits for the fractional part, unsigned). (a) Determine the closest binary representation. (b) Calculate the absolute error. (c) Calculate the relative error to three significant figures.
- 1.Step 1: Convert the integer part 6 to 4-bit binary: 6 = 0110_2.
- 2.Step 2: Approximate the fractional part 0.7 using 4 fractional bits with weights 0.5, 0.25, 0.125, 0.0625. Testing combinations: 0.5 + 0.125 + 0.0625 = 0.6875 (binary 0.1011). The next value is 0.5 + 0.25 = 0.75 (binary 0.1100). The difference from 0.7 is |0.7 - 0.6875| = 0.0125, whereas |0.7 - 0.75| = 0.05. Therefore, 0.1011_2 is closest.
- 3.Step 3: Combine integer and fractional parts: represented value = 0110.1011_2 = 6 + 0.6875 = 6.6875.
- 4.Step 4: Calculate absolute error: |True Value - Approximated Value| = |6.7 - 6.6875| = 0.0125.
- 5.Step 5: Calculate relative error: Absolute Error / True Value = 0.0125 / 6.7 = 0.00186567... = 0.00187 (or 0.187%).
Question: Explain how rounding errors can accumulate in an iterative loop calculating running financial totals, and describe one software technique to mitigate this issue.
- 1.Step 1: Identify the source of error: In each iteration, floating-point operations on non-power-of-two fractions (e.g. £0.10) introduce a tiny representation/rounding error due to finite mantissa precision.
- 2.Step 2: Explain accumulation: When operations are repeated thousands or millions of times in a loop, these small discrepancies compound monotonically, leading to substantial drift from the mathematically correct balance.
- 3.Step 3: Propose a mitigation technique: Store currency values as integers representing the smallest unit (e.g., pence or cents rather than pounds or dollars) or use a specialised arbitrary-precision decimal data type (e.g., Python Decimal or Java BigDecimal) instead of standard binary floating-point types.