public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* `std::stod ("nan")` returns negative NaN
@ 2018-08-13 15:16 Masamichi Hosoda
  2018-08-13 16:53 ` Stephen John Smoogen
  0 siblings, 1 reply; 32+ messages in thread
From: Masamichi Hosoda @ 2018-08-13 15:16 UTC (permalink / raw)
  To: cygwin; +Cc: trueroad

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

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2018-08-20 18:06 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-13 15:16 `std::stod ("nan")` returns negative NaN Masamichi Hosoda
2018-08-13 16:53 ` Stephen John Smoogen
2018-08-13 23:46   ` Duncan Roe
2018-08-14  0:46     ` Stephen John Smoogen
2018-08-14  1:10       ` Masamichi Hosoda
2018-08-14  2:31         ` strtod ("nan") returns negative NaN (was `std::stod ("nan")` returns negative NaN) Masamichi Hosoda
2018-08-14  3:25           ` strtod ("nan") returns negative NaN Steven Penny
2018-08-14  4:46           ` Masamichi Hosoda
2018-08-14  9:56             ` Corinna Vinschen
2018-08-14 10:39               ` Corinna Vinschen
2018-08-14 12:18                 ` Masamichi Hosoda
2018-08-14 13:23                   ` Corinna Vinschen
2018-08-14 13:41                     ` Stephen John Smoogen
2018-08-14 15:25                     ` Heavenly Avenger
2018-08-14 15:54                       ` Corinna Vinschen
2018-08-14 17:08                         ` Heavenly Avenger
2018-08-14 16:05                     ` Masamichi Hosoda
2018-08-14 19:24                     ` Steven Penny
2018-08-14 21:45                       ` Andy Moreton
2018-08-14 22:23                         ` Stephen John Smoogen
2018-08-15  0:02                           ` Eric Blake
2018-08-15  7:36                             ` Steven Penny
2018-08-21  3:18                             ` Brian Inglis
2018-08-14 19:44                 ` Achim Gratz
2018-08-21 13:28                   ` Brian Inglis
2018-08-14 15:05               ` Masamichi Hosoda
2018-08-14 15:21                 ` Masamichi Hosoda
2018-08-14 15:35                 ` Heavenly Avenger
2018-08-14 20:05                 ` Joseph Myers
2018-08-14 20:19                   ` Joseph Myers
2018-08-15  8:51                   ` Masamichi Hosoda
2018-08-15 12:55                     ` Masamichi Hosoda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).