Arbitrary precision integer arithmetic: ceiling?

Alasdair amca01 at gmail.com
Sat Mar 8 18:11:53 EST 2008


I need to apply the ceiling function to arbitrary sized (long) integers. 
However, division automatically returns the type of its operands, so that,
for example: math.ceil(7/4) returns 1.  I can use float, as in:
math.ceil(7/float(4)), except that for very large integers float causes an
unacceptable loss of precision.

What is the best way of finding a ceiling of a quotient of arbitrary sized
integers?

Thanks,
Alasdair



More information about the Python-list mailing list