Compile-time evaluation of real expressions?

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Jan 6 14:21:00 PST 2012


Hi All,

As I understand it, compile-time execution *should* be able to evaluate
floating-point functions, correct? Currently, I have this code:

        private static real cross_angles[6] = [
                real.nan,
                real.nan,
                real.nan,
                atan(sqrt(5)),
                PI_4,
                atan(sqrt(5)-2)
        ];

But the compiler is complaining:

/mnt/1/usr/include/d2/4.6/std/math.d:623: Error: asm statements cannot be interpreted at compile time
/mnt/1/usr/include/d2/4.6/std/math.d:591: Error: cannot evaluate atan2(x,1.0e+0L) at compile time

Is this an artifact of using gdc-4.6 instead of dmd? Or are certain
floating-point functions not allowed in compile-time expressions?

Thanks!

P.S. I just starting learning and using D recently -- and totally loving
it.


T

-- 
Knowledge is that area of ignorance that we arrange and classify. -- Ambrose Bierce


More information about the Digitalmars-d-learn mailing list