Hi all, am i right suspecting that only the first half of the PD_BADFLOAT macro is optimized away? (because otherwise the optimizer were buggy, weren't it?) Then, there's another possibility to test for almost denormals, suggested on the musicdsp site:
#define IS_ALMOST_DENORMAL(f) (fabs(f) < 3.e-34)
probably that's not much slower on modern cpus... should be profiled though
best, Thomas
----- Original Message ----- From: "Krzysztof Czaja" czaja@chopin.edu.pl To: "guenter geiger" geiger@xdv.org Cc: pd-list@iem.at Sent: Saturday, June 26, 2004 5:14 PM Subject: Re: [PD] Lost at compilig cyclone ;-((((
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.
PD-list mailing list PD-list@iem.at to manage your subscription (including un-subscription) see http://iem.at/cgi-bin/mailman/listinfo/pd-list