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

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 4 11:53:23 PDT 2016


On 8/4/2016 7:08 AM, Andrew Godfrey wrote:
> 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.

Also, carefully reading the C Standard, D's behavior is allowed by the C 
Standard. The idea that C requires rounding of all intermediate values to the 
target precision is incorrect, and is not "C-like". C floating point semantics 
can and do vary from platform to platform, and vary based on optimization 
settings, and this is all allowed by the C Standard.

It has been proposed many times that the solution for D is to have a function 
called toFloat() or something like that in core.math, which guarantees a round 
to float precision for its argument. But so far nobody has written such a function.


More information about the Digitalmars-d mailing list