Hi Chris On Mon, Aug 27, 2007 at 11:07:00AM -0700, Christopher Barker wrote: > Is the kahan_sum closer? -- it should be, though compensated summation > is really for adding LOTS of numbers, for 4, it's pointless at best. > Anyway, binary floating point has its errors, and compensated summation > can help, but it's still not exact for numbers that can't be exactly > represented by binary. > > i.e. if your result is within 15 decimal digits of the exact result, > that's as good as it gets.
I find this behaviour odd for addition. Under python: In [7]: 0.8+0.2 > 1.0 Out[7]: False but using the Pyrex module, it yields true. You can find the code at http://mentat.za.net/html/refer/somesumbug.tar.bz2 and compile it using pyrexc sum.pyx ; python setup.py build_ext -i When you run the test, it illustrates the problem: Sum: 1.00000000000000000000000000000000000000000000000000 Is greater than 1.0? True Cheers Stéfan _______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
