[docs] Bugs in Python3 division and right-shift docs
georg at python.org
Tue Oct 8 21:47:53 CEST 2013
-----BEGIN PGP SIGNED MESSAGE-----
Am 27.02.2013 21:30, schrieb Albert Hofkamp:
> While reporting a doc bug in the right-shift operator, I found another one
> in the division description. I combined them both below.
> " ... 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?
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?
thanks for the suggestions; they are now incorporated and will appear online soon.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.21 (GNU/Linux)
-----END PGP SIGNATURE-----
More information about the docs