Subject: Re: [Boost-bugs] [Boost C++ Libraries] #5689: lexical_cast must understand "inf" and "nan"
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-02-16 17:24:44
#5689: lexical_cast must understand "inf" and "nan"
--------------------------------------+-------------------------------------
Reporter: apolukhin | Owner: apolukhin
Type: Support Requests | Status: reopened
Milestone: Boost 1.48.0 | Component: lexical_cast
Version: Boost Development Trunk | Severity: Regression
Resolution: | Keywords: inf nan fininte
--------------------------------------+-------------------------------------
Changes (by apolukhin):
* cc: antoshkka@⦠(added)
* status: closed => reopened
* resolution: fixed =>
* type: Bugs => Support Requests
Comment:
Replying to [comment:5 anonymous]:
> using 1.48 version of lexical_cast works for "nan" but throws a error
for "NaN". I do not think there is a formal specification for Not-A-Number
in string form, but "NaN" is a common usage form.[[BR]]
There is a formal specification for Not-A-Number strings. According to
standatd strtod, strtof, and strtold, scanf, sscanf and fscanf functions
must parse NaN like that:
{{{
The expected form of the subject sequence is an optional plus or minus
sign, then one of
the following:
â INF or INFINITY, ignoring case
â NAN or NAN(n-char-sequenceopt), ignoring case in the NAN part, where:
...
}}}
[[BR]]
Last time I`ve been confused by printf functions, they have more strict
rules for outputting NaNs:
{{{
A double argument representing an infinity is converted in one of the
styles
[-]inf or [-]infinity â which style is implementation-defined. A
double argument representing a NaN is converted in one of the styles
[-]nan or [-]nan(n-char-sequence) â which style, and the meaning of
any n-char-sequence, is implementation-defined. The F conversion specifier
produces INF, INFINITY, or NAN instead of inf, infinity, or nan,
respectively.
}}}[[BR]]
[[BR]]
Great thanks for reporting this bug![[BR]]
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5689#comment:6> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC