This code
import std.stdio;
void main()
{
real r = 0.5000000894069671353303618843710864894092082977294921875;
writefln("r = %a", r);
double d = r;
writefln("d = %a", d);
float f = r;
writefln("f = %a", f);
}
compiled with dmd and -m64 prints
r = 0x1.000002fffffffcp-1
d = 0x1.000003p-1
f = 0x1.000004p-1
but the float value should be 0x1.000002p-1.
This is caused by dmd doing a conversion to double first for f = r, e.g.:
fld tbyte ptr 010h[RBP]
fstp qword ptr -010h[RBP]
movsd XMM0,-010h[RBP]
cvtsd2ss XMM0,XMM0
This works correctly for -m32 or LDC or GDC.
This code
compiled with dmd and
-m64printsbut the float value should be 0x1.000002p-1.
This is caused by dmd doing a conversion to double first for f = r, e.g.:
This works correctly for -m32 or LDC or GDC.