`std::stod ("nan")` returns negative NaN
Masamichi Hosoda
trueroad@trueroad.jp
Mon Aug 13 15:16:00 GMT 2018
Hi
I've found a curious behavior about `std::stod ("nan")` on Cygwin.
Only on Cygwin, `std::stod ("nan")` returns negative NaN.
On Linux etc., `std::stod ("nan")` returns positive NaN.
Here is a reproduction code.
```
// g++ -std=c++11 foobar.cc
#include <iostream>
#include <limits>
#include <string>
int main ()
{
std::cout << "stod (\"nan\") = "
<< std::stod ("nan")
<< std::endl;
std::cout << "stod (\"-nan\") = "
<< std::stod ("-nan")
<< std::endl;
std::cout << "quiet_NaN () = "
<< std::numeric_limits<double>::quiet_NaN ()
<< std::endl;
}
```
The result on Cygwin 2.10.0 64 bit (g++ 7.3.0):
```
stod ("nan") = -nan
stod ("-nan") = nan
quiet_NaN () = nan
```
The result on MinGW-w64 64 bit (g++ 4.9.2):
```
stod ("nan") = nan
stod ("-nan") = nan
quiet_NaN () = nan
```
The result on Ubuntu 16.04 LTS 64 bit (g++ 5.4.0):
```
stod ("nan") = nan
stod ("-nan") = nan
quiet_NaN () = nan
```
The result on FreeBSD 10.1 64 bit (clang++ 3.4.1):
```
stod ("nan") = nan
stod ("-nan") = nan
quiet_NaN () = nan
```
Is it correct that returning negative NaN on Cygwin?
Thanks.
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list