2009/3/8 <farsi...@gmail.com>: >>>> 4 / 5.0 > 0.800000000000000004 >>>> 0.8 * 5 > 4.0 > > python 2.6.1 on mac. What the hell is going on here?
I know this has already been answered in detail, but one thing that it's easy for those new to floating point issues to miss is that fractions that can be expressed exactly in decimal can end up as recurring decimals in binary. 0.8 looks nice and tidy, but in binary (if I get this right) it's 0.1100110011001100..., recurring ad infinitum. The computer has to truncate it somewhere. -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list