Live data from Hacker News

Floats Don't Agree with Themselves

docs.merca.earth

11–20 of 36 posts

Re: Floats Don't Agree with Themselves

#11
post #7

Not 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.

Same. I now tend to simply abandon writing when I see those tell tale signs

Re: Floats Don't Agree with Themselves

#13
post #12

If the original code was written in Rust, then I don't think the Rust compiler is allowed to do any of these "optimizations" of rewriting floating point expressions.

The C compiler also isn't allowed to do all of them. However some people use fast-math or compilers that default to fast-math to break the rules. Some older targets also may use the 80 bit fpu, which is its own mess and any sane compiler will default to properly sized SSE instructions instead.

Re: Floats Don't Agree with Themselves

#14
post #7

Not 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.

I also got turned off after the very first paragraph. Too bad, because the content itself might be fine, but the AI language has become repulsive.

Re: Floats Don't Agree with Themselves

#16
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/

Re: Floats Don't Agree with Themselves

#17
post #4

I love seeing a Shewchuk citation other than my ML background of learning conjugate gradient! He is truly a great educator!

Yeah, in general, this is a problem that people have spent a lot of time thinking about; while floating-point numbers can be finicky, they're what you have to work with if you have inputs at multiple scales.

(Meanwhile, I wonder why it's a fair bit harder to look up Ozaki et al.'s optimized version [0] compared to Shewchuk's original paper [1], unless perhaps later authors have found it to be no improvement at all.)

[0] https://www.tuhh.de/ti3/paper/rump/OzBueOgOiRu15.pdf

[1] https://people.eecs.berkeley.edu/~jrs/papers/robust-predicat...

Re: Floats Don't Agree with Themselves

#18

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/

On the other hand, if you store a small integer in a float it is generally reliable to compare to it. E.g., setting a float to zero and comparing whether the float is zero.

Re: Floats Don't Agree with Themselves

#19
post #7

Not 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

#20
post #19
post #7

Not 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.

It sounds authoritative so people would respond positively to it when presented with it during training.
Post reply on HN