Commit 70a66c9d authored by Fred Drake's avatar Fred Drake

Add notes to __builtin__.float() and string.atof() that the NaN and Inf

results are possible but non-portable.
parent d60ec8f1
...@@ -231,13 +231,17 @@ removed. ...@@ -231,13 +231,17 @@ removed.
\begin{funcdesc}{float}{x} \begin{funcdesc}{float}{x}
Convert a string or a number to floating point. If the argument is a Convert a string or a number to floating point. If the argument is a
string, it must contain a possibly signed decimal or floating point string, it must contain a possibly signed decimal or floating point
number, possibly embedded in whitespace, or be \code{'NaN'} (case number, possibly embedded in whitespace; this behaves identical to
insensitive); this behaves identical to \code{string.atof(\var{x})}. Otherwise, the argument may be a plain
\code{string.atof(\var{x})}. If the string is \code{'NaN'}, the or long integer or a floating point number, and a floating point
IEEE ``Not a Number'' value is returned. Otherwise, the argument number with the same value (within Python's floating point
may be a plain or long integer or a floating point number, and a precision) is returned.
floating point number with the same value (within Python's floating
point precision) is returned. \strong{Note:} When passing in a string, values for NaN\index{NaN}
and Infinity\index{Infinity} may be returned, depending on the
underlying C library. The specific set of strings accepted which
cause these values to be returned depends entirely on the C library
and is known to vary.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{getattr}{object, name} \begin{funcdesc}{getattr}{object, name}
......
...@@ -59,11 +59,15 @@ The functions defined in this module are: ...@@ -59,11 +59,15 @@ The functions defined in this module are:
\begin{funcdesc}{atof}{s} \begin{funcdesc}{atof}{s}
Convert a string to a floating point number. The string must have Convert a string to a floating point number. The string must have
the standard syntax for a floating point literal in Python, the standard syntax for a floating point literal in Python,
optionally preceded by a sign (\samp{+} or \samp{-}), or be optionally preceded by a sign (\samp{+} or \samp{-}). Note that
\code{'NaN'} (case insensitive) to indicate the IEEE ``Not a this behaves identical to the built-in function
Number'' value. Note that this behaves identical to the built-in \function{float()}\bifuncindex{float} when passed a string.
function \function{float()}\bifuncindex{float} when passed a
string. \strong{Note:} When passing in a string, values for NaN\index{NaN}
and Infinity\index{Infinity} may be returned, depending on the
underlying C library. The specific set of strings accepted which
cause these values to be returned depends entirely on the C library
and is known to vary.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{atoi}{s\optional{, base}} \begin{funcdesc}{atoi}{s\optional{, base}}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment