"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
| On Sat, 08 Mar 2008 17:09:11 -0800, Mark Dickinson wrote:
|
| > On Mar 8, 6:26 pm, Paul Rubin <http://[EMAIL PROTECTED]> wrote:
| >> Alasdair <[EMAIL PROTECTED]> writes:
| >> > What is the best way of finding a ceiling of a quotient of arbitrary
| >> > sized integers?
| >>
| >> ceiling(a/b) = (a+b-1)//b
| >
| > I prefer:
| >
| > ceiling(a/b) = -(-a)//b

Obvious typo: -(-a)//b == a//b

This should be -(-a//b) == -((-a)//b)

| Unfortunately it doesn't give the right answer.
| Looks like you've confused ceiling() and floor().
|
| (And the ease that these mistakes can happen is why such fundamental
| functions should be in the standard library, no matter how easy they are
| to implement.)

I'll let Paul say whether is was a typo, due to answering too quickly, or a 
logic error, but I suspect the former.  *Any* expression can be mistyped.

tjr





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

Reply via email to