Nope chistop... A little test, shall we:
Code:
#include <stdint.h>
int64_t f( double x ) { return x; }
int g( double x, int64_t y ) { return (x - y) * 100; }
With this you'll get:
Code:
f:
cvttsd2si rax, xmm0
ret
g:
pxor xmm1, xmm1
cvtsi2sdq xmm1, rdi
subsd xmm0, xmm1
mulsd xmm0, QWORD PTR .LC0[rip] ; .LC0 hold the encoded double 100.0
cvttsd2si eax, xmm0
ret
The first one, CVTTSDSI is a convertion WITH truncation, the second one (on g()) just gets the integral part again, but the calculation is made with rounding on... What I did is to strip the integer part of the double value... 0.3, indeed isn't representable in floating point, nor 0.1, 0.2, 0.4, 0.6, 0.7, 0.8 or 0.9. Floating point is a representation of a FRACTION in the format:
Where s, f and e are integers (encoded in floating point structure) and P is the precision of the type, in bits (53 for double). There is no f and e which will give you exactly 0.3.