Mathematics I / Searching and Sorting
Practice question · Multiple choice

Summing a million floating-point numbers from smallest to largest is more accurate than from largest to smallest. Why does order affect a sum?

Hints
  1. The gap between representable floats grows with magnitude. Ask what that does to a small addend.
  2. Add 1 to 10¹⁷ in floating point. What do you get?
Show the answer

C. Because adding a tiny number to a huge total can round away entirely

Why

Once the total is large, the spacing between representable values exceeds the small addends and they vanish on contact. Ascending order keeps the accumulator small for as long as possible, and Kahan summation goes further by tracking the discarded remainder explicitly.

Read the lesson: Searching and Sorting →

Practise Searching and Sorting

The app has 6 more questions on this lesson, and keeps your place in the course. Mathematics I is free to start.

More questions on Searching and Sorting