[uClibc] Is there a workaround for this floating point bug?
David Wuertele
dave-gnus at bfnet.com
Sun Aug 10 01:44:26 UTC 2003
The bug demonstrated by the program below is a showstopper for my
project. If I can't fix it or find a workaround, I'll have to trash
all my porting efforts and move back to glibc. Can anyone out there
reproduce it? Does anyone have any ideas how I might work around it?
Thanks,
Dave
Add equal parts mipsel, gcc-3.3, and uClibc to the program below and
stir. Serve on your favorite embedded system.
#include <stdio.h>
int main ()
{
double thisdub = 0.1;
if (thisdub != 0.1) { fprintf (stderr, "doubles are hosed!\n"); return 0; }
fprintf (stderr, "if %f and %f don't both equal 0.100000, suspect fprintf\n",thisdub, 0.1);
unsigned long height1 = 120;
unsigned long height2 = 1200;
float scale1 = (float)height1 / (float)height2;
double scale2 = (double)height1 / (double)height2;
double height3 = height2 * scale1;
unsigned long height4 = (unsigned long) height3;
fprintf (stderr, "if %f and %d aren't close to %d, suspect float operations\n",
height3, height4, height1);
return 0;
}
More information about the uClibc
mailing list