Problem whit float precision, 1.6 Windows 98

piet at cs.uu.nl piet at cs.uu.nl
Wed Sep 13 09:18:14 EDT 2000


>>>>> "Juan Huertas" <jhg at galdon.com> (JH) writes:

JH> Thank You, Remco.
JH> But there are other problems whit the precision, for example:

>>>> round(2020.685,2)
JH> 2020.6900000000001

JH> Acording the Python Documentation, round(v,n):

JH> Return the floating point value x rounded to "n digits after the decimal
JH> point"

Well, try what 2020.69 would output.
And then try round(2020.685,2)==2020.69
Floating point is very tricky.
This is the way it works; if you don't know it, don't use it.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl



More information about the Python-list mailing list