How deterministic is floating point inaccuracy?

From what I understand you’re only guaranteed identical results provided that you’re dealing with the same instruction set and compiler, and that any processors you run on adhere strictly to the relevant standards (ie IEEE754). That said, unless you’re dealing with a particularly chaotic system any drift in calculation between runs isn’t likely to result in buggy behavior.

Specific gotchas that I’m aware of:

  1. some operating systems allow you to set the mode of the floating point processor in ways that break compatibility.

  2. floating point intermediate results often use 80 bit precision in register, but only 64 bit in memory. If a program is recompiled in a way that changes register spilling within a function, it may return different results compared to other versions. Most platforms will give you a way to force all results to be truncated to the in memory precision.

  3. standard library functions may change between versions. I gather that there are some not uncommonly encountered examples of this in gcc 3 vs 4.

  4. The IEEE itself allows some binary representations to differ… specifically NaN values, but I can’t recall the details.

Leave a Comment