diff options
author | Guido van Rossum <guido@python.org> | 2001-07-12 11:27:16 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-07-12 11:27:16 (GMT) |
commit | bf5a774bcb0a9cdac2c0671819c0165d2a00afbb (patch) | |
tree | 76656aa93f73a3d31f544a321ea95cb8a551c5f0 /Doc/lib | |
parent | 0ec9abaa2b5f85837feae5c6cbc1491f2f34f16f (diff) | |
download | cpython-bf5a774bcb0a9cdac2c0671819c0165d2a00afbb.zip cpython-bf5a774bcb0a9cdac2c0671819c0165d2a00afbb.tar.gz cpython-bf5a774bcb0a9cdac2c0671819c0165d2a00afbb.tar.bz2 |
On int/long to the negative int/long power, let float handle it
instead of raising an error. This was one of the two issues that the
VPython folks were particularly problematic for their students. (The
other one was integer division...) This implements (my) SF patch
#440487.
Diffstat (limited to 'Doc/lib')
-rw-r--r-- | Doc/lib/libfuncs.tex | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/Doc/lib/libfuncs.tex b/Doc/lib/libfuncs.tex index e5699c9..e493375 100644 --- a/Doc/lib/libfuncs.tex +++ b/Doc/lib/libfuncs.tex @@ -494,13 +494,16 @@ the interpreter. \begin{funcdesc}{pow}{x, y\optional{, z}} Return \var{x} to the power \var{y}; if \var{z} is present, return \var{x} to the power \var{y}, modulo \var{z} (computed more - efficiently than \code{pow(\var{x}, \var{y}) \%\ \var{z}}). - The arguments must have - numeric types. With mixed operand types, the rules for binary - arithmetic operators apply. The effective operand type is also the - type of the result; if the result is not expressible in this type, the - function raises an exception; for example, \code{pow(2, -1)} or - \code{pow(2, 35000)} is not allowed. + efficiently than \code{pow(\var{x}, \var{y}) \%\ \var{z}}). The + arguments must have numeric types. 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, a negative second argument + would raise an exception.) \end{funcdesc} \begin{funcdesc}{range}{\optional{start,} stop\optional{, step}} |