Always false float comparisons

Ola Fosheim Grøstad via Digitalmars-d digitalmars-d at puremagic.com
Tue May 17 10:06:44 PDT 2016


On Tuesday, 17 May 2016 at 14:05:54 UTC, Matthias Bentrup wrote:
> If you try to make compile-time FP math behave exactly like 
> run-time FP math, you'd not only have to use the same precision 
> in the compiler, but also the same rounding mode, denormal 
> handling etc., which can be changed at run time 
> (http://dlang.org/phobos/core_stdc_fenv.html), so the exact 
> same piece of code can yield different results based on the 
> run-time FP-context.

Yes, heading rounding mode is an absolute requirement. If the 
system don't heed the rounding mode then it will change the 
semantics and break the program when computing upper vs lower 
bounds.

I've never liked the stateful approach to rounding. If I was to 
design a language I probably would make it part of the type or 
operator or something along those lines.




More information about the Digitalmars-d mailing list