summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2002-11-08 05:30:23 (GMT)
committerRaymond Hettinger <python@rcn.com>2002-11-08 05:30:23 (GMT)
commit0da7f39a7cc93eb4940e6350ab69ae939192f2d4 (patch)
tree9ee86039fb511b74f0574035f4e5f5002682820a /Doc
parent0ec1ddcdcfaef4a4525f3f8a26d59804deef767d (diff)
downloadcpython-0da7f39a7cc93eb4940e6350ab69ae939192f2d4.zip
cpython-0da7f39a7cc93eb4940e6350ab69ae939192f2d4.tar.gz
cpython-0da7f39a7cc93eb4940e6350ab69ae939192f2d4.tar.bz2
Closes SF bug #634069 reporting the docs on the ** operator were out
of date and did not reflect the current CPython implementation.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/ref/ref5.tex18
1 files changed, 14 insertions, 4 deletions
diff --git a/Doc/ref/ref5.tex b/Doc/ref/ref5.tex
index f554ab4..af1fa19 100644
--- a/Doc/ref/ref5.tex
+++ b/Doc/ref/ref5.tex
@@ -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}}