Bitten by a bug
- Posted by DB James <larch at adelphia.net> Oct 19, 2005
- 593 views
Hi, This may be known to some others, but I wasted some time figuring this out, so I'm passing along the information. There is a problem dividing atoms by a number that only showed up when the program was compiled to C. In the process of clarifying it, I wrote this little test program: -------------------------------------------- --test.ex --test effect of compiling using WATCOM C/C++ Version 11.0c --run first without compiling, then with compiling integer fn atom x puts(1,"Adding data to result.txt\n\n") fn=open("c:\\euphoria\\result.txt","a") puts(fn,"Test results for values of x (set at 75 before each operation)\n\n") x=75 x=x/100 printf(fn,"With \"x=x/100\": x=%f\n",x) x=75 x=x/100.0 printf(fn,"With \"x=x/100.0\": x=%f\n",x) x=75 x/=100 printf(fn,"With \"x/=100\": x=%f\n",x) x=75 x/=100.0 printf(fn,"With \"x/=100.0\": x=%f\n",x) puts(fn,"\nEnd test results for values of x\n\n") close(fn) puts(1,"Done, any key...\n") while equal(get_key(),-1) do end while -------------------------------------------- The results were as follows: First, without compiling the test program: -------------------------------------------- Test results for values of x (set at 75 before each operation) With "x=x/100": x=0.750000 With "x=x/100.0": x=0.750000 With "x/=100": x=0.750000 With "x/=100.0": x=0.750000 End test results for values of x -------------------------------------------- Then, with compiling: -------------------------------------------- Test results for values of x (set at 75 before each operation) With "x=x/100": x=44169448.000000 With "x=x/100.0": x=0.750000 With "x/=100": x=44169452.000000 With "x/=100.0": x=0.750000 End test results for values of x -------------------------------------------- Ironically, when I was trying to track down this bug, I tested for everything but the real culprit, so lost some time... --Quark