Did you know that a computer can add 0.1 and 0.2 and display 0.30000000000000004, even though a school mathematics answer is 0.3? The unusual digits are not proof that decimal addition has changed. They are a clue that the computer stored approximations of the two input numbers.
The immediate answer: many programs represent ordinary numeric values using binary floating-point, a finite collection of binary digits. The exact decimal fractions one tenth and two tenths cannot be stored exactly in that common format. The approximations can make a tiny difference visible when their sum is converted back to decimal text. In exact arithmetic, 0.1 + 0.2 = 0.3; in a particular machine representation, the stored result can be slightly above the stored representation of 0.3.
- For school arithmetic, the mathematical answer is 0.3.
- In a language such as Python, the expression
0.1 + 0.2commonly displays0.30000000000000004. - A long string of digits does not indicate that the program is more accurate than the mathematics.
- For money, scores and measurements, first decide whether you need exact decimal values, appropriate rounding or a stated tolerance.
- Always distinguish the number stored, the number displayed and the real-world quantity it is supposed to describe.
A diagnosis before a coding lesson
Write these three statements where the learner can see them: A: 0.1 + 0.2 = 0.3. B: a computer may show 0.30000000000000004 for the same expression. C: therefore one tenth is secretly larger than one tenth. Ask which statements can be true together. A and B can be true; C is false. If the learner rejects A, they are confusing representation with mathematics. If they reject B, they may be assuming that computers always store decimal numbers exactly.
The next question reveals more: does 0.5 + 0.25 have the same difficulty? In ordinary binary arithmetic, 0.5 = 1/2 and 0.25 = 1/4 have exact finite binary representations. Their sum is exactly 0.75 in the common format, barring unrelated operations. The contrast turns a strange screen result into a testable idea.
Why base ten and base two behave differently
In decimal notation, 1/10 has a finite representation: 0.1. But 1/3 has a repeating decimal representation: 0.3333… . You can write more digits, but a fixed number of places cannot encode the exact one-third. Binary has a related limitation: its place values are 1/2, 1/4, 1/8 and so on. Some decimal fractions that terminate neatly in base ten repeat when expressed in base two.
The common binary64 floating-point format stores finite approximations for 0.1 and 0.2. It also stores a finite approximation for a directly entered 0.3. The rounded binary result of adding the first pair need not be the same bit pattern as the separately rounded 0.3 value. That explains why some exact-equality comparisons fail. This is not randomness or a broken addition sign; it is a predictable consequence of representation and rounding.
A hand-checkable example without memorising computer bits
This is an invented classroom exercise. A pupil uses a card system that can store only two digits after a decimal point. It must approximate one third as 0.33 and two thirds as 0.67. Adding the two stored approximations gives 1.00, which happens to equal one. But approximating one third as 0.33 and doubling it gives 0.66, which differs from the separately stored 0.67. The underlying fractions have not changed. Different sequences of approximation and arithmetic can lead to different stored answers.
Now change the system to binary. Fractions such as 1/2 and 1/4 terminate. One tenth does not. The example is an analogy about finite digits, not a claim that real computers store only two decimal places. For the actual floating-point case, a familiar Python evaluation is 0.1 + 0.2 → 0.30000000000000004. The difference from exact 0.3 is around 0.00000000000000004, extremely small for many uses but important for exact comparisons.
Why spreadsheet displays may hide the effect
Many spreadsheet programs show rounded results according to a chosen number format. A cell may display 0.30 while the internal calculation retains more precision. Another application may print a long decimal. The interface is not a trustworthy description of every stored bit. Ask students to examine the application’s numeric rules and formula settings rather than assume every product or cell must behave exactly like a Python terminal.
The reverse problem also happens. A document formatted to two decimal places can make unequal numbers look equal. In school project data, 2.345 and 2.354 could both look like 2.35 under some formatting conventions, even though the underlying values are not identical. Students should learn the distinction between display rounding and changing stored values.
Four ways to check a calculation responsibly
- Estimate first: one tenth plus two tenths is three tenths; a result near 0.3 is sensible, while 3.0 would be a major error.
- Check the representation: confirm whether the system uses binary floating-point, decimal arithmetic, integer arithmetic or a library with its own rules.
- Use tolerances where appropriate: if approximate quantities should agree within a justified error range, compare their difference with that tolerance instead of demanding exact bitwise equality.
- Choose exact representation where required: quantities such as currency cents can be modelled as integers under an appropriate monetary policy, or with a decimal type whose inputs are created from exact decimal strings.
An independent three-question practice ladder
Guided: express 0.5 and 0.25 as fractions with denominators that are powers of two. Answer: 1/2 and 1/4; their sum is 3/4 = 0.75. Explain why no repeating binary fraction is needed.
Supported: decide whether 0.1 has a finite binary fraction. It does not. Write one sentence explaining why rounding to finite binary digits can leave a small representation difference. A correct explanation should mention the storage system rather than say the computer cannot add.
Independent: suppose a program reports 0.30000000000000004 for a lab calculation. Should a school report claim a measurement accurate to seventeen decimal places? No. The report must reflect the resolution and uncertainty of the measurements, their units and any stated rounding rule. An extra numerical digit does not create evidence the instrument never collected.
Misconceptions worth fixing explicitly
One misconception says floating-point is always inaccurate. A binary floating-point number can represent many values exactly; the question is whether the particular value and operation fit its finite format. Another says any unexpected digit should simply be deleted. Blind rounding can hide a substantial bug. First establish the intended mathematical model and acceptable precision, then apply an explicit numerical policy.
A third misconception is that 0.30000000000000004 is the correct school answer. It is a computer output in a specified context, not a replacement for exact decimal arithmetic. Likewise, if a program compares two calculated physical measurements, it may need an uncertainty-aware method rather than an arbitrary universal tolerance. For high-stakes financial, scientific or engineering systems, follow the relevant domain’s numerical standards and testing practices.
What learners, teachers and parents can do
A learner can build a two-column notebook: mathematical value on the left, stored or displayed result on the right. Include 1/2, 1/4, 1/10 and 1/5, then write a causal explanation for each difference. The progress test is not remembering the famous 0.30000000000000004 string. It is predicting, for an unfamiliar fraction, whether finite binary representation may be an issue.
Teachers can ask students to reproduce the example in a suitable programming environment, then vary the operands and note what changes. Do not assess learners solely on using one particular program or printed output; show the representation rule. Parents can ask, ‘What does the long output tell us about the storage method?’ rather than ‘Which calculator is wrong?’ A brief discussion gives numerical accuracy a purpose.
Did you know? The strongest numerical habit is to name the kind of equality
Exact symbolic equality, equality of stored machine values, equality after display rounding and practical agreement within measurement uncertainty are not interchangeable. Students who can explain which one a question requires are learning a larger idea: evidence is meaningful only when its representation matches its purpose.
Frequently asked questions
Does every computer show this result?
No. Languages, arithmetic libraries, input conversion, compiler behaviour and display formatting differ. The example is characteristic of common binary floating-point calculations, not a universal claim about all calculators.
Is this why a bank account sometimes has a missing cent?
Floating-point handling can contribute to such problems in poorly designed numerical workflows, but a banking discrepancy cannot be diagnosed from that fact alone. Monetary systems need appropriate decimal or fixed-point models and defined rounding rules.
Can I compare approximate numbers with == in code?
Sometimes, especially for exactly representable values or exact identifiers. For results of approximate computations, decide what tolerance or numerical comparison method is justified for that problem and follow the language’s guidance.
Where is the authoritative explanation?
See the Python documentation on floating-point representation and its limits, which explains why common binary formats approximate decimal 0.1. The classroom card system above is an invented analogy, not a quotation from that documentation.
Useful related reading
Continue with eduKate’s existing guide on numbers stored as text in spreadsheet SUM and the explanation of ten-bit values and their code range. Explore the Education Hub and the unchanged Clementi Mathematics tutorial reference for diagnosis-first, independent checking.
The aim is not to fear computers or decimals. It is to ask what was represented, what operation was performed, what was displayed and how the answer should be checked. That question travels far beyond a famous line of digits.