GCSE · Computer Science · Eduqas · Spec C500QS
Truncation errors
Press run. No red text, no crash, no warning. And the answer is wrong. How can a program be wrong and say nothing?
Computer Science · Truncation errors
Be the computer: chop, then keep going
Each pass adds 0.19 to total, then truncate(…, 1) keeps one decimal place and cuts the rest off.
You are the computer. Call each marked step before the table shows it. Nothing is really run: every value is the lesson's. truncate(x, 1) is a made-up function for this lesson that keeps 1 decimal place and cuts the rest off. The program has no exact or lost; we added those two columns to show what a perfect calculator would hold and how much has gone missing.
total = 0for i = 1 to 4total = truncate(total + 0.19, 1)next iprint(total)
| i | total | exact | lost |
|---|---|---|---|
| 0 | 0 | 0 |
Step 1. total starts at 0. This first row is worked for you.
Cut the extra digits off. Do not round.
Why it happens
Reason it through
Why does a computer end up chopping the end off a number?
First link · your turn
A computer has to keep every number somewhere. How much room does each number get?
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
What happens when a computer chops digits off a number, and why the program carries on anyway
What you need to know
- A computer stores each number in a fixed number of bits or digits, so there is only so much room.
- A value that needs more digits than that, like 1/3 = 0.3333..., has its extra digits cut off.
- Truncating means keeping the digits up to a chosen place and discarding every digit after it, whatever its value.
- The kept digits are not changed. So 3.789 truncated to two decimal places is 3.78, not 3.79.
Have a goYour turn: a program truncates 6.451 to one decimal place. What does it store?
6.4
Keep the digits up to the first decimal place and cut the rest. Rounding would have given 6.5, but truncation never rounds.
- Converting a real number to an integer by truncation discards the fractional part, so 7.9 becomes 7.
- A truncation error is an inaccuracy in a number caused by digits being cut off without rounding.
- Its size is the true value minus the truncated value: 3.789 − 3.78 = 0.009.
Have a goA program truncates 2.846 to one decimal place and stores 2.8. How big is the truncation error?
0.046
True value minus truncated value: 2.846 − 2.8 = 0.046. Subtract the stored value from the true one, not the other way round.
- Truncation always moves a value towards zero, so a truncated positive number is never larger than the true value.
Have a goDev swears his program truncated 2.7 to 3 and 'saved a bit of space'. Dev is confidently wrong. What went wrong?
Truncating 2.7 gives 2, not 3.
Truncation moves a positive number towards zero, so it is never larger than the true value. 3 is bigger than 2.7, so that was rounding.
- A program with a truncation error still runs, but its results are inaccurate.
- Reuse truncated values in later calculations and the errors can build up into a noticeably inaccurate result.
The big picture
Truncation cuts a number's extra digits off without rounding, so the stored value is a little off the true one. The gap, true value minus truncated value, is the truncation error. It happens because a computer stores numbers in a fixed number of bits or digits. The program still runs, but if truncated values are reused the errors can build up into a noticeably inaccurate result.
Key points
Worked example
Problem
A program truncates 12.3456 to three decimal places. What value does it store, and what is the truncation error?
⚠ Watch out
Rounding instead of truncating. Truncating 2.678 to two decimal places gives 2.67, not 2.68: the 8 is just cut off, and it cannot push the 7 up.
Memory hook
Truncate is a guillotine, not a rounder: it chops the tail off and never nudges what is left.
Check yourself
Without looking back: truncate 8.762 to one decimal place and work out the truncation error. Then say whether the program that did this would crash, and why not.
Flashcards
(10)What is a truncation error?
What does truncating a number to a chosen number of places do?
Truncating or rounding: which one can change the last kept digit?
Truncation error: do you subtract true from truncated, or truncated from true?
Which way does truncation move a value?
Why do truncation errors happen?
Why can a fixed number of digits not store 1/3 exactly?
What happens when a real number is converted to an integer by truncation?
Does a truncation error make a program crash?
What can happen when truncated values are used again in further calculations?
Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.
Learning with Lightbulb is opening soon
You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.
Keep me postedMore Eduqas GCSE Computer Science topics
How this lesson was checked. This Eduqas GCSE Computer Science (specification C500QS)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 16 November 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.