Arbitrary precision integer arithmetic: ceiling?

Paul Rubin http
Sun Mar 9 00:32:04 EST 2008


Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:
> Unfortunately that doesn't work reliably.
> 
> >>> a, b = 9007199254741000.0, -3.0
> >>> a/b
> -3002399751580333.5
> >>> (a+b-1)//b  # should be -3002399751580333
> -3002399751580332.0

I should have mentioned (a+b-1)//b expects a and b to be positive
integers.  



More information about the Python-list mailing list