floating-WTF
dennis luehring
dl.soluz at gmx.net
Tue Jan 24 08:01:28 PST 2012
can you give us a complete out-of-the-box compileable example (with
imports,main,etc.) with both examples the working/and nonworking
does it work correct with dmd(32bit)?
is this "calculate2" needed to reproduce the behavior?
and what compiler did you test: dmd64, (dmd32?), ...?
Am 24.01.2012 16:20, schrieb sclytrack:
>
>
> void calculate2(float a, float b)
> {
> float s1 = 1.0 - a;
> float s2 = a * b;
> writeln(s2);
> writeln(a * b);
> }
>
> ----------------
> Output:
> t*b= 0
> t*b= 1.5
> ----------------
>
>
> assume CS:.text._D4main10calculate2FffZv
> _D4main10calculate2FffZv:
> push RBP
> mov RBP,RSP
> sub RSP,020h
> movss -010h[RBP],XMM0
> movss -8[RBP],XMM1
> mov RAX,03FF0000000000000h
> mov -020h[RBP],RAX
> movsd XMM2,-020h[RBP]
> cvtss2sd XMM1,XMM1
> subsd XMM2,XMM1
> ------conversion but xmm2 is no longer used
> cvtsd2ss XMM2,XMM2
> ------precision error multiplication
> mulss XMM1,XMM0
> movss -018h[RBP],XMM1
> movss XMM0,-018h[RBP]
> call _D3std5stdio14__T7writelnTfZ7writelnFfZv at PC32
> movss XMM0,-8[RBP]
> movss XMM1,-010h[RBP]
> mulss XMM0,XMM1
> call _D3std5stdio14__T7writelnTfZ7writelnFfZv at PC32
> leave
> ret
> nop
> nop
> nop
>
> ------------
> DMD64 D Compiler v2.057
> Ubuntu 11.10
More information about the Digitalmars-d-learn
mailing list