News for hackers. Stuff that matters.
Re:Compiler Warnings by loeg on Friday January 25, 2019 @11:10AM (#18999205)
C doesn't require IEEE754. It's strongly suggested as normative, Appendix F. But not required; after all, C17/18 still does not require two's complement for signed integers. C's model allows for very weird underlying machines.

x86 is extremely popular and 80 bit long doubles using the old FPU model can introduce weirdness on that platform. And yes, reducing the 80 bit long doubles to 64 bits after every operation significantly impacts performance. Or used to.

Re:Compiler Warnings by olliej on Friday January 25, 2019 @01:01PM (#19000497)
While f80 had some quirks it is an ieee754 floating point unit, and has all the ieee precision and semantics.

But my point was that saying floating point was somehow a magical non-deterministic beast is incorrect, and saying == shouldn't be allowed because of that is incorrect. Pretty much the same arguments can be made for integer arithmetic (after all x/y is undefined behavior if it overflows or y is zero even for integers, and just as with floating point you need to understand the behavior of arithmetic)

Re:Compiler Warnings by telendram on Saturday January 26, 2019 @03:11PM (#19008175)
That's a huge stretch. Integer arithmetic is perfectly portable. Defined operations have bit-exact defined results, reproducible on any platform.

In contrast, the result of basic floating point operations is not. You may live in a world were you use a single cpu type, and a single OS, and a single compiler, in which case, it might appear to you as defined. But anyone involved in some portability across multiple systems know how improbable it is to rely on floating point for anything exact. Actually, don't. ever.

For anything which requires exact results, use integer instead.

Re:Compiler Warnings by olliej on Saturday January 26, 2019 @05:16PM (#19008879)
No floating point is exact and consistent and incredibly well defined. Floating point is not exact but neither are integers. Floating point is 100% deterministic.

Things that differ: bit wise representation for non-ieee formats. Things that don’t differ: numeric result.

Basically for any arithmetic operation, with a given significand and exponent size in some rounding mode, there is a single correct result. Different implementations do not produce different results.