Closes SF bug #634069 reporting the docs on the ** operator were out

of date and did not reflect the current CPython implementation.
This commit is contained in:
Raymond Hettinger 2002-11-08 05:30:23 +00:00
parent 0ec1ddcdcf
commit 0da7f39a7c

View file

@ -599,10 +599,20 @@ The power operator has the same semantics as the built-in
\function{pow()} function, when called with two arguments: it yields
its left argument raised to the power of its right argument. The
numeric arguments are first converted to a common type. The result
type is that of the arguments after coercion; if the result is not
expressible in that type (as in raising an integer to a negative
power, or a negative floating point number to a broken power), a
\exception{TypeError} exception is raised.
type is that of the arguments after coercion.
With mixed operand types, the coercion rules for binary arithmetic
operators apply. For int and long int operands, the result has the
same type as the operands (after coercion) unless the second argument
is negative; in that case, all arguments are converted to float and a
float result is delivered. For example, \code{10**2} returns \code{100},
but \code{10**-2} returns \code{0.01}. (This last feature was added in
Python 2.2. In Python 2.1 and before, if both arguments were of integer
types and the second argument was negative, an exception was raised).
Raising \code{0.0} to a negative power results in a
\exception{ZeroDivisionError}. Raising a negative number to a
fractional power results in a \exception{ValueError}.
\section{Unary arithmetic operations \label{unary}}