3 ms·
What a strange comment to say "A value of exactly 1.0, say from the result of min(1.0,f), is not going to arbitrarily change to a different value." Christ man,
by noobermin 5y ago
What a strange comment to say "A value of exactly 1.0, say from the result of min(1.0,f), is not going to arbitrarily change to a different value." Christ man, floating point arithmetic is on computers, it's definitely deterministic, no one is saying it's indeteriminable, lol, including the author. It's not like we're off in LSD space where numbers change meaning from moment to moment, it's only that there is information lost in each operation that lead to accumulating error such that exact comparisons usually do not express what you mean to compare in computer programs. That's all, and I don't think the OP is saying anything else.
Other than that I'm not sure what you're adding. The point is people are unclear when they write code because they do not understand floats, and because few people really understand round-off error, they should as a rule compare with np.isclose unless, as you say, they now for a fact they expect a specific floating point number (although the times that happens is by and far the minority in actual code).
- eru 5y agoIn spirit you are right. Alas, floating point arithmetic is not necessarily deterministic in the sense that running the same Python or C code twice is guaranteed to give you the some results. First, your compiler is often allowed to do weird things. (Like compile the same code in different ways.) And there's some weirdness with the state of flags that might be different from iteration to iteration. See https://randomascii.wordpress.com/2013/07/16/floating-point-determinism/ https://randomascii.wordpress.com/2013/07/16/floating-point-... for some more information.