Why is std.math slower than the C baseline?

Timon Gehr timon.gehr at gmx.ch
Fri Jun 5 14:52:16 UTC 2020


On 05.06.20 05:37, Walter Bright wrote:
> On 6/4/2020 7:40 AM, Timon Gehr wrote:
>> In one of my projects I had to manually re-implement all functions 
>> that currently forward to libc, because libc is not portable.
> 
> How about adding these as PRs to Phobos?

Their main feature is portability and I hacked them together quickly. 
They are unlikely to beat any given libc on other metrics. (e.g., sin 
and cos are based on cubic interpolation of large lookup tables, good 
enough to get somewhat close to full float precision.)

Ideally, the standard math functions in Phobos would be portable 
_because they give correct results_, like the basic arithmetic operators 
and the square root function in C99.

This seems promising, but I'm not sure what it's current state is: 
https://hal-ens-lyon.archives-ouvertes.fr/ensl-01529804/file/crlibm.pdf

Also, it's GPL, so we can't port it to Phobos directly:
https://gforge.inria.fr/scm/browser.php?group_id=5929&extra=crlibm


More information about the Digitalmars-d mailing list