[dmd-internals] Pure CTFE-able std.math

Iain Buclaw ibuclaw at ubuntu.com
Tue Jul 16 11:03:36 PDT 2013


On 15 July 2013 10:46, Iain Buclaw <ibuclaw at ubuntu.com> wrote:
> Don,
>
> I'm in the middle of doing pure real implementations of the elementary
> math functions in std.math in D for the @safe/pure/nothrow routines
> that call impure extern(C) mathlib as a fallback if D_InlineAsm is not
> defined.
>

This is pretty much complete with the exception of lrint not yet implemented.

One thing I've noted running the unittests are that while the
functions produce accurate results, this is only true up to 64bit
precision.  The remaining 16bits bits going slightly off target.

eg:
exp(1.0L) == E;  // true
exp(3.0L) == E*E*E;  // false


--
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


More information about the dmd-internals mailing list