summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2008-04-19 21:35:35 +0000
committerMark Dickinson <dickinsm@gmail.com>2008-04-19 21:35:35 +0000
commit48f7a4aabb056120f5e9f9843b7350e7739e4706 (patch)
tree2c641b73b341f49d720cb56590c67a9e02f9bb55
parent1df986b403ec239f0f4f26cf5edc3729b144de53 (diff)
downloadcpython-git-48f7a4aabb056120f5e9f9843b7350e7739e4706.tar.gz
Correct documentation for math.pow;
0**nan is nan, not 0. (But nan**0 and 1**nan are 1.) Also fix minor typo: 'quite NaN' -> 'quiet NaN'
-rw-r--r--Doc/library/math.rst12
1 files changed, 8 insertions, 4 deletions
diff --git a/Doc/library/math.rst b/Doc/library/math.rst
index ad36f9234d..2c1677cbdb 100644
--- a/Doc/library/math.rst
+++ b/Doc/library/math.rst
@@ -154,11 +154,15 @@ Power and logarithmic functions:
.. function:: pow(x, y)
- Return ``x**y``. ``1.0**y`` returns *1.0*, even for ``1.0**nan``. ``0**y``
- returns *0.* for all positive *y*, *0* and *NAN*.
+ Return ``x`` raised to the power ``y``. Exceptional cases follow
+ Annex 'F' of the C99 standard as far as possible. In particular,
+ ``pow(1.0, x)`` and ``pow(x, 0.0)`` always return ``1.0``, even
+ when ``x`` is a zero or a NaN. If both ``x`` and ``y`` are finite,
+ ``x`` is negative, and ``y`` is not an integer then ``pow(x, y)``
+ is undefined, and raises :exc:`ValueError`.
.. versionchanged:: 2.6
- The outcome of ``1**nan`` and ``0**nan`` was undefined.
+ The outcome of ``1**nan`` and ``nan**0`` was undefined.
.. function:: sqrt(x)
@@ -290,7 +294,7 @@ The module also defines two mathematical constants:
:exc:`OverflowError` isn't defined, and in cases where ``math.log(0)`` raises
:exc:`OverflowError`, ``math.log(0L)`` may raise :exc:`ValueError` instead.
- All functions return a quite *NaN* if at least one of the args is *NaN*.
+ All functions return a quiet *NaN* if at least one of the args is *NaN*.
Signaling *NaN*s raise an exception. The exception type still depends on the
platform and libm implementation. It's usually :exc:`ValueError` for *EDOM*
and :exc:`OverflowError` for errno *ERANGE*.