Hello Joanne,

> ... [float problem] ...
> I get True returned. Can anyone tell me whats going on and how I can
> avoid the problem. Thanks

If you want to be truly accurate, you can use gmpy.mpq (http://
gmpy.sourceforge.net/).
>>> a = [0.2, 0.2, 0.2, 0.1, 0.2, 0.1]
>>> b = [0.2, 0.2, 0.2, 0.2, 0.1, 0.1]
>>> qa = [gmpy.mpq(int(i * 10), 10) for i in a]
>>> qb = [gmpy.mpq(int(i * 10), 10) for i in b]
>>> sum(qa)
mpq(1)
>>> sum(qb)
mpq(1)
>>> sum(qa) == sum(qb)
True

HTH,
--
Miki <[EMAIL PROTECTED]>
http://pythonwise.blogspot.com

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to