Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 70a66c9

Browse files
committed
Add notes to __builtin__.float() and string.atof() that the NaN and Inf
results are possible but non-portable.
1 parent d60ec8f commit 70a66c9

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

Doc/lib/libfuncs.tex

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,17 @@ \section{Built-in Functions \label{built-in-funcs}}
231231
\begin{funcdesc}{float}{x}
232232
Convert a string or a number to floating point. If the argument is a
233233
string, it must contain a possibly signed decimal or floating point
234-
number, possibly embedded in whitespace, or be \code{'NaN'} (case
235-
insensitive); this behaves identical to
236-
\code{string.atof(\var{x})}. If the string is \code{'NaN'}, the
237-
IEEE ``Not a Number'' value is returned. Otherwise, the argument
238-
may be a plain or long integer or a floating point number, and a
239-
floating point number with the same value (within Python's floating
240-
point precision) is returned.
234+
number, possibly embedded in whitespace; this behaves identical to
235+
\code{string.atof(\var{x})}. Otherwise, the argument may be a plain
236+
or long integer or a floating point number, and a floating point
237+
number with the same value (within Python's floating point
238+
precision) is returned.
239+
240+
\strong{Note:} When passing in a string, values for NaN\index{NaN}
241+
and Infinity\index{Infinity} may be returned, depending on the
242+
underlying C library. The specific set of strings accepted which
243+
cause these values to be returned depends entirely on the C library
244+
and is known to vary.
241245
\end{funcdesc}
242246

243247
\begin{funcdesc}{getattr}{object, name}

Doc/lib/libstring.tex

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,15 @@ \section{\module{string} ---
5959
\begin{funcdesc}{atof}{s}
6060
Convert a string to a floating point number. The string must have
6161
the standard syntax for a floating point literal in Python,
62-
optionally preceded by a sign (\samp{+} or \samp{-}), or be
63-
\code{'NaN'} (case insensitive) to indicate the IEEE ``Not a
64-
Number'' value. Note that this behaves identical to the built-in
65-
function \function{float()}\bifuncindex{float} when passed a
66-
string.
62+
optionally preceded by a sign (\samp{+} or \samp{-}). Note that
63+
this behaves identical to the built-in function
64+
\function{float()}\bifuncindex{float} when passed a string.
65+
66+
\strong{Note:} When passing in a string, values for NaN\index{NaN}
67+
and Infinity\index{Infinity} may be returned, depending on the
68+
underlying C library. The specific set of strings accepted which
69+
cause these values to be returned depends entirely on the C library
70+
and is known to vary.
6771
\end{funcdesc}
6872

6973
\begin{funcdesc}{atoi}{s\optional{, base}}

0 commit comments

Comments
 (0)