That's why they always teach: "never compare floats for equality." Or maybe they don't teach that anymore, I dunno. See link for the Fundamental Axiom of Floating Point Arithmetic: All floating point arithmetic operations are exact up to a relative error of epsilon_machine. https://www.johnbcoughlin.com/posts/floating-point-axiom/
Floats Don't Agree with Themselves
21–30 of 36 posts
Re: Floats Don't Agree with Themselves
#22Not sure if this was written with AI assistance of not, but I've become allergic to linguistic triples as LLMs use them so much, reading "Same code. Same input. Different answer" makes me not want to read the rest.
Its weird that almost every AI generated blurb tends to have that. Usually followed by "Its not just X, its Y". I wonder where they picked that up from.
Re: Floats Don't Agree with Themselves
#23I wish the blog would reveal the values of the 3 floats that make their cross_sign(A, B, C) to give different results in different platforms.
The main caveat is that on x86 targets without SSE2, LLVM is deeply wired to use the x87 instructions without attempting to emulate the IEEE overflow/underflow behavior [1]. So perhaps it could be possible to exhibit a discrepancy, but only by compiling for i586 and an ancient target-cpu. It's very doubtful that this was the cause of the original client vs. server issue in TFA's introduction.
[0] https://rust-lang.github.io/rfcs/3514-float-semantics.html
Re: Floats Don't Agree with Themselves
#24IEEE 754 absolutely does pin down behavior.
Re: Floats Don't Agree with Themselves
#25Not sure if this was written with AI assistance of not, but I've become allergic to linguistic triples as LLMs use them so much, reading "Same code. Same input. Different answer" makes me not want to read the rest.
Re: Floats Don't Agree with Themselves
#26Not sure if this was written with AI assistance of not, but I've become allergic to linguistic triples as LLMs use them so much, reading "Same code. Same input. Different answer" makes me not want to read the rest.
We seem to have lost the war for people to find their own voice, the AI articles are getting widely upvoted, and people pointing out they are AI are no longer getting traction, people don't seem to care.
Re: Floats Don't Agree with Themselves
#27Ah yes -ffast-math, also known as -fincorrect-math
Re: Floats Don't Agree with Themselves
#28Huh? This is just false, isn't it? AFAIK, it pins down behavior, and the differences come from things like changing the order of operations (i.e. accumulating rounding error in a different order). I'm not an expert, though.
Re: Floats Don't Agree with Themselves
#29Re: Floats Don't Agree with Themselves
#30This seems to be AI bullshit. You can easily get deterministic floats that give the same results everywhere. Just don't use -ffast-math.
(And NaN payloads in general are a mess across platforms and ABIs, but that can be solved by treating all NaNs as identical.)