std.math performance (SSE vs. real)

Element 126 via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 30 09:29:05 PDT 2014


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;
}


More information about the Digitalmars-d mailing list