[docs] Bugs in Python3 division and right-shift docs

Albert Hofkamp alberth289346 at gmail.com
Thu Feb 28 00:03:28 CET 2013


While reporting a doc bug in the right-shift operator, I found another
one in the division description. I combined them both below.


http://docs.python.org/3/reference/expressions.html?highlight=shift#binary-arithmetic-operations
A quote:
" ... The / (division) and // (floor division) operators yield the
quotient of their arguments. The numeric arguments are first converted
to a common type. Integer division yields a float, while floor
division of integers results in an integer; ..."

The term "Integer division" does not get defined here.  Perhaps
"Division of integers yields ..." would be better?




http://docs.python.org/3/reference/expressions.html?highlight=shift#shifting-operations
A quote from 6.7 (Shifting operations) of the python 3 language reference:

"...These operators accept integers as arguments. They shift the first
argument to the left or right by the number of bits given by the
second argument.
A right shift by n bits is defined as division by pow(2,n). A left
shift by n bits is defined as multiplication with pow(2,n). ..."

By the latter sentence, I can interpret 2 >> 5 as 2 / pow(2, 5), which
is 0.0625. On the other hand, 2 >> 5 is 0 according to Python 3.3 .
Perhaps it should say "floor division" in the explanation above?

Albert


More information about the docs mailing list