News for hackers. Stuff that matters.
Re:Lies My Calculator and Computer Told Me [pdf] by BeetleB on Tuesday September 19, 2023 @10:58AM (#37570854)
Everyone is correcting you, but no one is pointing out the real culprit. Floating point operations are not the same as math operations (i.e. +, -, *, / behave differently).
Re:Lies My Calculator and Computer Told Me [pdf] by ska on Tuesday September 19, 2023 @12:33PM (#37572425)
I think what you mean here is that floating point numbers an the usual operators (+,*) and inverses (-,/) do not form a field, but people often behave as if they do.

This isn't a "culprit" so much as a fact along with common confusion.

Re:Lies My Calculator and Computer Told Me [pdf] by gilcot on Tuesday September 19, 2023 @01:11PM (#37573014)
IEEE 754 is well defined so that $a+b=b+a$ But it can't give you warranty that $(a+b)+c=a+(b+c)$ (well known error propagation issue)
Re:Lies My Calculator and Computer Told Me [pdf] by BeetleB on Tuesday September 19, 2023 @05:21PM (#37576915)
IEEE guarantees commutativity, but does not guarantee the correctness of a+b.

My point is that floating point numbers are real numbers, but the usual operations on them will not give you the same results as the operations on real numbers.

Re:Lies My Calculator and Computer Told Me [pdf] by nayuki on Tuesday September 19, 2023 @08:01PM (#37578771)
IEEE does guarantee the correctness of a+b in the sense that it will return the floating-point number that is closest to the real number that would've been computed with infinite precision.
Re:Lies My Calculator and Computer Told Me [pdf] by BeetleB on Wednesday September 20, 2023 @12:33PM (#37586312)
> IEEE does guarantee the correctness of a+b in the sense that it will return the floating-point number that is closest to the real number that would've been computed with infinite precision.

Until you deal with overflow.

And to be frank, this is just redefining "correctness". If you want to view FPs as real numbers (which they are), there's nothing wrong with pointing out that real number operations will give you incorrect results (even ignoring overflow).

> There's no randomness or fuzziness in floating-point rounding.

I did not imply there was.

Re:Lies My Calculator and Computer Told Me [pdf] by gilcot on Tuesday September 19, 2023 @09:34PM (#37579417)
FP are part of R, like Q or D sets. (I think it should be considered/seen as a subset of decimal numbers set.)
Re:Lies My Calculator and Computer Told Me [pdf] by BeetleB on Wednesday September 20, 2023 @12:34PM (#37586314)
Nothing I said implied they weren't.