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

Skip to content

Commit 951eea4

Browse files
committed
atof() description: Add information about accepting 'NaN' to produce
the NaN value.
1 parent 594b3d6 commit 951eea4

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

Doc/lib/libfuncs.tex

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,13 @@ \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;
235-
this behaves identical to \code{string.atof(\var{x})}.
236-
Otherwise, the argument may be a plain or
237-
long integer or a floating point number, and a floating point number
238-
with the same value (within Python's floating point precision) is
239-
returned.
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.
240241
\end{funcdesc}
241242

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

Doc/lib/libstring.tex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ \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{-}). Note that
63-
this behaves identical to the built-in function
64-
\function{float()}\bifuncindex{float} when passed a string.
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.
6567
\end{funcdesc}
6668

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

0 commit comments

Comments
 (0)