In <[EMAIL PROTECTED]>, Dan Bishop
wrote:

> On Jun 7, 8:30 pm, Some Other Guy <[EMAIL PROTECTED]> wrote:
>> Since this just involves doubling you can avoid multiplying altogether
>> and just use this:
>>
>> def rounddiv(a,b):
>>   return int((a+a+b)/(b+b))
>>
>> That's 3 integer adds and 1 integer divide.  The int() cast is just
>> there is case somebody passes in floats for a or b; if you know you're
>> only going to have integer arguments you don't need it.
> 
> The // operator was added to the language for a reason.  I'm surprised
> at how few Pythonistas are using it six years later.

It would just document intent here because it still gives `float` results
if used with at least one `float` as operands:

In [1]: 10.0 // 2
Out[1]: 5.0

Ciao,
        Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to