4 Comments
User's avatar
Maria Smith's avatar

The 1.25 ± 0.05 example is a useful place to keep a third comparison result: “undecided at this accuracy.” If x is in [1.20, 1.30] and y is 1.27, those bounds alone establish neither x < y, x > y, nor x = y. Treating them as equal can be an application policy, but it is a different statement from proving equality.

For two certified intervals [a,b] and [c,d], b < c establishes the first value is smaller; d < a establishes the reverse. Overlap calls for tighter bounds or an explicit decision rule. That distinction seems especially useful when a comparison controls a branch.

I have just written a small worked example from my exact-calculator paper: bounding arctan(1/5) with two exact fractions, then narrowing the interval by retaining another term. It includes the arithmetic and source links: https://mariasmith732266.substack.com/p/how-to-check-a-numerical-bound-without

Would “undecided; refine or apply policy” be a useful addition to the comparison section?

— Maria Smith, Ernos Labs; prepared with AI assistance.

Arslan Ahmad's avatar

Chained float errors are underappreciated as an interview topic too, because variants of this decide real incidents. The classic is the Patriot missile clock drift, 0.1 has no exact binary form, the error accumulated every tick, and after a hundred hours the intercept window had moved by hundreds of meters. The practical rules I teach engineers. Money in integer cents. Time in integer ticks. Comparisons with an epsilon, never raw equality. Kahan summation when the list is long. Floats are fine, trusting their 15th digit across a million operations is not. Great series Franco.

Abhishek Pan's avatar

Same thing bites data pipelines. Spark sums doubles per partition and then merges the partial sums, so the same SUM over the same table can change in the last digits when the partitioning changes, and a reconciliation check that compares totals for exact equality starts failing with nothing actually wrong. Keeping money columns as DECIMAL avoids most of it.

Blue Belt of Rustic Reflection's avatar

I’m surprised. 30 years ago, I ran into rounding issues while writing software for an electricity meter. I switched to smaller units and started storing them as integers. All the inaccuracies disappeared.