On Oct 25, 3:44 pm, gershar <gerrys...@gmail.com> wrote: > It looks like a rounding problem but on the surface there is nothing > to round. I am aware that there are rounding limitations with floating > point arithmetic but the value passed to int() is always correct.
No, it isn't: >>> for x in xrange(5): ... i += 0.1 ... z = i * 10.0 ... print ... print z ... print repr(z) ... print int(z) ... -499.0 -499.0 -499 -498.0 -498.0 -498 -497.0 -496.99999999999994 -496 -496.0 -495.99999999999994 -495 -495.0 -494.99999999999994 -494 Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list