Why don't we switch to C like floating pointed arithmetic instead of automatic expansion to reals?

Andrew Godfrey via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 4 07:08:30 PDT 2016


On Wednesday, 3 August 2016 at 23:00:11 UTC, Seb wrote:
> There was a recent discussion on Phobos about D's floating 
> point behavior [1]. I think Ilya summarized quite elegantly our 
> problem:
>
> [...]

In my experience (production-quality FP coding in C++), you are 
in error merely by combining floating point with exact comparison 
(==). Even if you have just one compiler and architecture to 
target, you can expect instability if you do this. Writing robust 
FP algorithms is an art and it's made harder if you use 
mathematical thinking, because FP arithmetic lacks many 
properties that integer or fixed-point arithmetic have.

I'm not saying D gets it right (I haven't explored that at all) 
but I am saying you need better examples.

Now, my major experience is in the context of Intel non-SIMD FP, 
where internal precision is 80-bit. I can see the appeal of 
asking for the ability to reduce internal precision to match the 
data type you're using, and I think I've read something written 
by Walter on that topic. But this would hardly be "C-like" FP 
support so I'm not sure that's he topic at hand.


More information about the Digitalmars-d mailing list