Always false float comparisons
Ola Fosheim Grøstad via Digitalmars-d
digitalmars-d at puremagic.com
Fri May 13 22:46:38 PDT 2016
On Saturday, 14 May 2016 at 01:26:18 UTC, Walter Bright wrote:
> BTW, I once asked Prof Kahan about this. He flat out told me
> that the only reason to downgrade precision was if storage was
> tight or you needed it to run faster. I am not making this up.
He should have been aware of reproducibility since people use
fixed point to achieve it, if he wasn't then shame on him.
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 C++ template parameters cannot be floating point, you use
std::ratio so you get exact rational number instead. This is to
avoid inaccuracy problems in the type system.
In interval-arithmetics you need to round up and down correctly
on the bounds-computations to get correct results. (It is ok for
the interval to be larger than the real result, but the opposite
is a disaster).
With reproducible arithmetics you can do advanced accurate static
analysis of programs using floating point code.
With reproducible arithmetics you can sync nodes in a cluster
based on "time" alone, saving exchanges of data in simulations.
There are lots of reasons to default to well defined floating
point arithmetics.
More information about the Digitalmars-d
mailing list