On Sat, 13 Apr 2013 18:36:21 +0200, Jeremy DeHaan <dehaan.jerem...@gmail.com> wrote:

I'm on Windows, and I my compilation was nothing more than "dmd -O -release main.d" to get the issue I described.

Turns out, the problem starts here:

    static const(float) pi = 3.141592654f;

If we compare that to std.math.PI, we see that they're different:

    >> writeln( 3.141592654f - std.math.PI );
    4.10207e-10

If, however, we assign these values to some temporary floats, we see that
they're equal:

    >> float a = 3.141592654f;
    >> float b = std.math.PI;
    >> writeln( a - b );
    0

Replace float with double or real in the above, and the difference reappears.

So, we have established that 3.141592654f is a valid approximation to pi for a float. The problem thus has to be one of precision. I'm not sure if it's a valid optimization for the compiler to use doubles instead of floats (it certainly seem innocuous enough). I'd say file a bug on it. Worst case, it gets closed as
invalid.

--
Simen

Reply via email to