hi Guenter,
this fails, though:
int result[25];
void pass1(void) { int i; float f = 0.0001, *fp = &f;
for (i=0;i<25;i++) {
*fp*=0.0001;
if (PD_BADFLOAT(*fp)) result[i] = 1;
else result[i] = 0;
}
}
void pass2(void) { int i; float f = 0.0001; for (i=0;i<25;i++) { f*=0.0001; if (result[i]) printf("%d badfloat %g %08x\n",i,f,*(int*)&f); else printf("%d goodfloat %g %08x\n",i,f,*(int*)&f); } }
If compiled with "gcc-3.3 -O6...", you will get:
... 8 goodfloat 9.99995e-41 000116c2 9 goodfloat 9.80909e-45 00000007 ...
while without "-O6" it works ok. The bottom line is, that I do not know the rules (if there are any).
Krzysztof
guenter geiger wrote: ...
I just tested this with gcc 3.3.4 from Debian and it seems to work.