while this is not directly related to chessprogramming (sorry for that but I consider chess programmers very good, that's why I'm asking:), I have run into a weird problem.
I'm getting denormal floats when converting from very small (near-zero) doubles.
I always thought that x87 automatically fixes these to zero when doing fst(p).
Is there a way to work around it (I'm currently fixing this manually which is not what I would consider elegant). Compiler: MSVC, no SSE, floating point model: strict.
Has anyone ever experienced similar problems?
Thanks
Martin
EDIT:
sample code:
Code: Select all
float f;
int main()
{
double d = -1e-300;
f = (float)d;
printf("f = %0.6f\n", f);
if ( !f )
f = 0.0f;
printf("f = %0.6f\n", f);
return 0;
}
Code: Select all
f = -0.000000
f = 0.000000