Skip to topic
    ← Back to course topics

    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

    1. 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
    1. 1Day 1-3: Master binary fractional conversion mechanics and identify which base-10 fractions recur in base-2.
    2. 2Day 4-6: Practice calculating absolute and relative errors for both fixed-point and normalised floating-point questions.
    3. 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)
    Calculate

    Perform mathematical operations step-by-step to arrive at a numerical result. Working must be shown to secure intermediate method marks.

    Explain

    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).

    Compare

    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)
    Pitfall: Confusing absolute error with relative error or forgetting that relative error is expressed as a fraction or percentage of the true value.
    ❌ Weak Answer (Loses Marks):The absolute error is 0.05, so the relative error is also 0.05.
    Example improved answer:Absolute error is the magnitude of the difference between the actual value and the approximated value: |Actual - Approximate|. Relative error is the absolute error divided by the actual value: |Actual - Approximate| / Actual, which can be multiplied by 100 to yield a percentage.
    Examiner Tip: Always state both formulas clearly before substituting numbers to secure method marks even if an arithmetic slip occurs.
    Pitfall: Assuming that numbers with terminating decimal representations (such as 0.1 or 0.2) can always be represented exactly in binary.
    ❌ Weak Answer (Loses Marks):0.1 has an exact representation because it only has one decimal place.
    Example improved answer:In base 10, 0.1 is 1/10. However, in base 2, fractions must be powers of 2 (1/2, 1/4, 1/8, etc.). The prime factorisation of 10 contains 5, which is not a power of 2, resulting in an infinitely recurring binary fraction (0.000110011...) that must be truncated or rounded, producing a representation error.
    Examiner Tip: Explicitly mention that only fractions with denominators that are powers of 2 can be represented exactly in binary floating-point systems.
    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. 1.Step 1: Convert the integer part 6 to 4-bit binary: 6 = 0110_2.
    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. 3.Step 3: Combine integer and fractional parts: represented value = 0110.1011_2 = 6 + 0.6875 = 6.6875.
    4. 4.Step 4: Calculate absolute error: |True Value - Approximated Value| = |6.7 - 6.6875| = 0.0125.
    5. 5.Step 5: Calculate relative error: Absolute Error / True Value = 0.0125 / 6.7 = 0.00186567... = 0.00187 (or 0.187%).
    Final Answer: Represented binary: 0110.1011; Absolute error = 0.0125; Relative error = 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. 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. 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. 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.
    Final Answer: Errors accumulate because small truncation errors compound across successive operations; mitigate by storing values as integer pennies or using arbitrary-precision decimal libraries.
    Active Recall Memory Test
    What is the mathematical formula for relative error?
    Key Fact: Relative Error = |Actual Value - Stored Approximate Value| / Actual Value.
    Why can the decimal value 0.75 be stored exactly in binary, but 0.7 cannot?
    Key Fact: 0.75 is 3/4 (which is 1/2 + 1/4, sum of negative powers of 2), whereas 0.7 has 10 as denominator, whose prime factor 5 cannot be formed by finite sums of negative powers of 2.
    What is catastrophic cancellation in floating-point arithmetic?
    Key Fact: The extreme loss of significant precision that occurs when two nearly equal numbers are subtracted, leaving only rounding error in the significant digits.
    Frequently Asked Questions
    Why does 0.1 + 0.2 equal 0.30000000000000004 in many programming languages?
    Neither 0.1 nor 0.2 can be represented exactly as finite binary fractions because their denominators contain the prime factor 5. Standard IEEE 754 64-bit floating-point stores them as close binary approximations. When these two approximations are added together, the tiny residual representation errors combine to produce a result marginally greater than 0.3.
    What is the difference between rounding error and truncation error?
    Truncation error occurs when bits beyond a certain precision limit are simply discarded without altering the remaining bits. Rounding error refers to the discrepancy caused by replacing a value with its nearest representable value according to a specific rounding rule (such as round-to-nearest-even). While truncation always rounds towards zero (or negative infinity depending on representation), rounding to nearest halves the maximum bound of representation error.
    Can rounding errors be completely eliminated in computing?
    They cannot be eliminated entirely for arbitrary real numbers or irrational numbers like pi. However, they can be avoided for specific domains like finance by using fixed-point integer scaling (storing pence instead of pounds) or arbitrary-precision decimal libraries that simulate base-10 arithmetic in software.
    How does mantissa size influence rounding errors compared to exponent size?
    The mantissa determines the precision (the number of significant figures), whereas the exponent determines the dynamic range (how large or small the number can be). Increasing the mantissa size reduces representation and rounding errors by providing more fractional bits, whereas increasing the exponent size only expands the range of numbers that can be represented without overflow or underflow.