[Python-Dev] rounding problem

Gary Herron gherron at islandtraining.com
Mon May 31 21:19:00 EDT 2004


On Monday 31 May 2004 06:08 pm, Norlin Abd Rahim wrote:
> Hi,
>
> I'm using python with zope. I used _.round and it seems like it is look
> unstable. For example if i have one number, 1130.975 and rounded it to 2
> decimal places, it will be 1130.97 and not 1130.98. But for certain numbers
> it will rounded correctly if the last digit is 5. I even used fixedpoint.py
> but still i've got the same problem. This applies only to numbers that have
> digit 5 after the decimal places that needs to be rounded.
>
> Any idea why?
>
> TIA

Perhaps the last digit is 5 only because the printing rounded
...4999... or some such up to 5.  Unless you KNOW that the number is
exactly 1130.975 (in its internal representation) then you must
consider this as a possibility.

Gary Herron





More information about the Python-Dev mailing list