Problems solved in full
-
Rounding 1,000 amounts to the nearest whole unit with a 98,351.63 true total 7 steps
A shop rounds each of 1,000 amounts to the nearest whole unit and adds them up. The true total is 98,351.63. Work out what the rounded total comes to under each rule, and decide which one the shop should use.
-
Settle the rule before the column means anything. Take 2.5. Half-up sends it to 3. Half-to-even sends it to 2, because 2 is the even neighbour.
-
Check that half-to-even alternates rather than always going down: 3.5 goes to 4 under both rules, because this time the even neighbour is the one above.
-
Now the column. Of the 1,000 amounts only 11 sit exactly on a tie, so the two half-rules agree on 989 of them and can differ by at most 11 β one unit per tie.
-
Add the rounded values. Half-up gives 98,360, which is 8.37 above the truth. Half-to-even gives 98,354, or 2.37 above. The 6 between them came from those 11 ties.
-
Most of that drift is not the ties at all β it is ordinary rounding, which on 1,000 ordinary amounts is about as likely to go either way. To see the rules themselves rather than the noise, switch the column to ties, where every value is one: half-up is then 500 too high and half-to-even is 6 out.
-
Try floor on the original column for contrast: 97,866, which is 486 short. Floor takes something from nearly every value instead of only from the ties, so its drift does not need ties to accumulate.
-
Which rule to use therefore depends on what is being protected. For a single receipt any half-rule will do, and the difference is never more than half a unit. Across a ledger, only a rule with no preferred direction leaves the total where it started.
Answer
98,360 under half-up, 98,354 under half-to-even, 97,866 under floor, against a true 98,351.63. The shop should use half-to-even β not because it is more accurate on any one amount, where it is sometimes worse, but because its errors have no direction and so do not accumulate. Half-up is wrong by half a unit on every tie it ever meets, upward, without exception.
-
-
1.005 to two places, and the tie that is not one 7 steps
Round 1.005 to two decimal places. Work out what the machine is really holding when you type that, then decide whether a spreadsheet answering 1.00 has made a mistake.
-
As a decimal it is a tie: 1.005 stands the same distance from 1.00 as from 1.01, so half-up sends it upward and the panel prints 1.01.
-
The machine is not holding a decimal. A double is a sum of powers of two, and 0.005 is one two-hundredth, whose denominator carries a 5Β² that no power of two can supply. The binary expansion never ends.
-
What gets stored is the nearest double, and it sits below 1.005 by about 1.07 Γ 10β»ΒΉβΆ. Compared exactly, that is not a tie at all, and half-up would send it down to 1.00.
-
The gap becomes visible the moment the value is scaled to be compared. 1.005 Γ 100 is 100.49999999999999, whose fractional part falls short of a half by 1.42 Γ 10β»ΒΉβ΄.
-
Which is why the rounding here snaps. Anything within 8 machine steps of a half is treated as a half, and at this size that window is 1.79 Γ 10β»ΒΉΒ³, more than ten times wider than the gap. The panel answers the question you asked about the decimal rather than the one the binary asked.
-
The tolerance is not free, and the column shows what it costs. A thousand values ending in .005, each pushed up by half a hundredth, carry the total 5.00 above the truth. Half-to-even splits the same ties and comes in at 0.07.
-
Two of the other presets are different in kind. 2.5 and 12.5 have exact binary forms, so they are ties inside the machine as well as on paper and no tolerance is involved. βExactly halfβ is a property of the decimal you typed, and it survives into the machine only for the halves that really are halves.
Answer
1.01, and a spreadsheet answering 1.00 is right about the number it holds and wrong about the number you typed. The stored value is 1.07 Γ 10β»ΒΉβΆ below 1.005, so an exact comparison never sees a tie, and the snap is what puts the answer back where a reader expects it. No rounding rule repairs the underlying problem. Money belongs in integer cents, or in a decimal type, where 1.005 is 1.005 and the question never comes up.
-
Learning path
Writing a number down
References (2)
- Why half-to-even is the default rather than the rule taught in school, and what else the standard fixes: IEEE, "IEEE Standard for Floating-Point Arithmetic." IEEE Std 754-2019, 2019.
- The long-form explanation of why 1.005 is not stored as 1.005, and what follows from it: D. Goldberg, "What Every Computer Scientist Should Know About Floating-Point Arithmetic." ACM Computing Surveys 23(1), 5β48, 1991.