Always false float comparisons

Ola Fosheim Grøstad via Digitalmars-d digitalmars-d at puremagic.com
Sat May 14 02:24:49 PDT 2016


On Saturday, 14 May 2016 at 09:11:49 UTC, QAston wrote:
> On Saturday, 14 May 2016 at 05:46:38 UTC, Ola Fosheim Grøstad 
> wrote:
>> In Java all compile time constants are done using strict 
>> settings and it provides a keyword «strictfp» to get strict 
>> behaviour for a particular class/function.
>
> In java everything used to be strictfp (and there was no 
> keyword), but it was changed to do non-strict arithmetic by 
> default after a backlash from numeric programmers.

Java had a healthy default, but switched in order to not look so 
bad in comparison to C on current day hardware. However, they 
retained the ability to get stricter floating point.

At the end of the day there is literally no end to how far you 
can move down the line of implementation defined floating point. 
Take a look at the ARM instruction set, it makes x86 look high 
level. You can even choose how many iterations you want for 
complex instructions (i.e. choose the approximation level for 
faster execution).

However, these days IEEE754-2008 is becoming available in 
hardware and therefore one is better off choosing the most 
well-defined semantics for the regular case. It means less 
optimization opportunities unless you specify relaxed semantics, 
but that isn't such a bad trade off as long as specifying relaxed 
semantics is easy.



More information about the Digitalmars-d mailing list