Back

Floating-Point Precision Pitfalls

A long-running tracking system counts time in tenth-of-a-second ticks and multiplies by a 24-bit copy of $0.1$. But $0.1$ has no exact binary form, and chopped to 24 bits it becomes $209715/2097152 = 0.0999999046\ldots$, so every tick is short by about $9.5\times10^{-8}$ s. The error is never reset while the system stays powered, so it grows in proportion to uptime. The tracker uses that clock to open a prediction gate, the window where it expects a fast moving object to be next; multiply the time error by the object's speed and the gate is displaced behind the true position. After roughly 100 hours the clock is off by 0.34 s, the gate is hundreds of metres behind the object, and the object slips outside the gate and is missed. The scene shows the gate walking off the object as uptime grows; the diagnostic plots the displacement against uptime and the gate's catch radius. One truncated constant, repeated billions of times, becomes a gross failure.

Figure 1. A prediction gate displaced by accumulated 24-bit clock error. Top: a fast object on a track and the catch gate the tracker opens for it, offset by the clock drift; when the offset exceeds the catch radius the object is missed. Bottom: gate displacement versus uptime against the catch radius, with the 100-hour reference marked. Method: exact IEEE chop error per tick times uptime times object speed.
uptime (h)18
object (m/s)1676

WHAT TO TRY

  • Just watch: the system clock ages on its own and the catch goes from centered, through edge catches, to a clean miss. The catch-confidence bar slides down continuously, there is no single instant it "switches off".
  • Grab the uptime slider to hold a moment: the tiny rounding of 0.1 per tick accumulates into the miss distance shown, growing in exact proportion to how long the system has been powered.
  • Park it near 100 hours: the gate is hundreds of metres behind the object, far outside the catch radius, and the object is missed.
  • Tick patched software: the drift vanishes, every catch is centered at any uptime. One corrected constant fixes it.