std.math performance (SSE vs. real)

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Fri Jun 27 22:28:11 PDT 2014


On 6/27/2014 11:47 AM, Kagamin wrote:
> I think, make real==double on x86-64, like on other architectures, because
> double is the way to go.

No.

Consider also that on non-Windows platforms, such a decision would shut D out 
from accessing C code written using long doubles.

BTW, there's a reason Fortran is still king for numerical work - that's because 
C compiler devs typically do not understand floating point math and provide 
crappy imprecise math functions. I had an argument with a physics computation 
prof a year back who was gobsmacked when I told him the FreeBSD 80 bit math 
functions were only accurate to 64 bits. He told me he didn't believe me, that C 
wouldn't make such mistakes. I suggested he test it and see for himself :-)

They can and do. The history of C, including the C Standard, shows a lack of 
knowledge of how to do numerical math. For example, it was years and years 
before the Standard mentioned what the math functions should do with infinity 
arguments.

Things have gotten better in recent years, but I'd always intended that D out of 
the gate have proper support for fp, including fully accurate math functions. 
The reason D re-implements the math functions in Phobos rather than deferring to 
the C ones is the unreliability of the C ones.


More information about the Digitalmars-d mailing list