Hrounding error

casevh casevh at gmail.com
Wed Jun 18 01:54:10 EDT 2008


On Jun 17, 10:47 pm, coop... at gmail.com wrote:
> Hi,
> I am new to python.  I was messing around in the interperator checking
> out the floating point handling and I believe I may have found a
> rounding bug:
>
> >>> 234 - 23234.2345
>
> -23000.234499999999
>
> This is not correct by my calculations.
>
> I am using python 2.5.2 in ubuntu 8.04.  I am wondering if this is a
> known bug, or if I am just not understanding some feature of python.
> Thanks for the help!
>
> -Cooper Quintinhttp://www.bitsamurai.net

It is a side-effect of binary floating-point.

http://www.python.org/doc/faq/general/#why-are-floating-point-calculations-so-inaccurate

casevh




More information about the Python-list mailing list