std.math performance (SSE vs. real)

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 30 09:33:39 PDT 2014


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.


More information about the Digitalmars-d mailing list