On GNU/Linux, and several other operating systems, the strtod function will accept the strings "inf" and "infinity" for an infinite value, and the string "nan" for a NaN (the tests are case insensitive). This is a convenient way to specify an infinite or NaN floating point value from the command line or in an input file.
Unfortunately, this does not work with operator>> in the current libstdc++. Here is a test case which I believe should pass, as a quality of implementation issue. It currently aborts. I haven't yet tested it with libstdc++ v2, but inspection suggests that it would have worked. #include <sstream> #include <cmath> int main () { std::istringstream sinf ("inf"); double d; sinf >> d; if (!sinf || !isinf (d)) abort (); std::istringstream sinfinity ("infinity"); sinfinity >> d; if (!sinfinity || !isinf (d)) abort (); std::istringstream snan ("nan"); snan >> d; if (!snan || !isnan (d)) abort (); exit (0); } -- Summary: operator>> to floating point variable does not support "inf", "infinity", or "nan" Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ian at airs dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27904