When is divmod(a,b)[0] == floor(a/b)-1 ?

kj no.email at please.post
Thu Sep 24 21:40:37 CEST 2009




The docs for divmod include the following:

    divmod(a, b)
    ...For floating point numbers the result is (q, a % b), where q
    is usually math.floor(a / b) but may be 1 less than that. ...

I know that floating point math can sometimes produce "unexpected"
results, so the above caveat is not entirely surprising.  Still,
I would find it helpful to see a specific example where
divmod(a, b)[0] is equal to math.floor(a/b)-1.  Does anybody know
one?

Thanks!

kynn 



More information about the Python-list mailing list