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'
This commit is contained in:
Mark Dickinson 2008-04-19 21:35:35 +00:00
parent 1df986b403
commit 48f7a4aabb
1 changed files with 8 additions and 4 deletions

View File

@ -154,11 +154,15 @@ Power and logarithmic functions:
.. function:: pow(x, y) .. function:: pow(x, y)
Return ``x**y``. ``1.0**y`` returns *1.0*, even for ``1.0**nan``. ``0**y`` Return ``x`` raised to the power ``y``. Exceptional cases follow
returns *0.* for all positive *y*, *0* and *NAN*. 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 .. 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) .. 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` isn't defined, and in cases where ``math.log(0)`` raises
:exc:`OverflowError`, ``math.log(0L)`` may raise :exc:`ValueError` instead. :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 Signaling *NaN*s raise an exception. The exception type still depends on the
platform and libm implementation. It's usually :exc:`ValueError` for *EDOM* platform and libm implementation. It's usually :exc:`ValueError` for *EDOM*
and :exc:`OverflowError` for errno *ERANGE*. and :exc:`OverflowError` for errno *ERANGE*.