union luai_Cast { double l_d; long l_l; };
#define lua_number2int(i,d) { volatile union luai_Cast u; \
u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
ftol()
Was this post helpful ?
Hallo,
an inlined version of ftol() as you can see below. This version works
normaly fine and very fast. But if I have started with direct3d my function
returns always 0! Where is the problem and what I have to do to let it work
under direct3d?
{
#ifdef __WINDOWS__
static const double magic = 6755399441055744.0; // 2^51 + 2^52
tmp += (x > 0) ? -0.499999999999 : +0.499999999999;
tmp += magic;
return *(long*)&tmp;
#else
return (long)x;
#endif
}
--------------------------------------------------------------------------------
Axel
Report Abuse
01 Nov 2005, 2:15 PM UTC
Jack Hoxley
ModeratorMVP
Was this post helpful ?
Direct3D changes the FPU flags when it starts up as an optimization... could well be interfering with your implementation
Forces Direct3D to not change the floating-point unit (FPU) control word, running the pipeline using the precision of the calling thread. Without this flag, Direct3D defaults to setting the FPU to single-precision round-to-nearest mode. Using this flag with the FPU in double-precision mode will reduce Direct3D performance.
Warning Portions of Direct3D assume FPU exceptions are masked. Unmasking such exceptions may lead to undefined behavior.
Jack
















