On Monday, 30 June 2014 at 16:29:06 UTC, Element 126 wrote:
On 06/29/2014 11:04 PM, John Colvin wrote:
[...]

mixin(`alias real` ~ (real.sizeof*8).stringof ~ ` = real;`);

is more useful to me.

Be careful : this code is tricky ! real.sizeof is the storage size, ie 16 bytes on x86_64.

The following happily compiles ;-)

import std.conv: to;

mixin(`alias real` ~ to!string(real.sizeof*8) ~ ` = real;`);

static assert(real128.mant_dig == 64);

void main() {

        real128 x = 1.0;
}

I knew there'd be something tricky in there. Thanks for spotting it.

Reply via email to