This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Floating point exception in strtod()
- From: Ken Brown <kbrown at cornell dot edu>
- To: cygwin <cygwin at cygwin dot com>
- Date: Sat, 7 Apr 2018 13:40:05 -0400
- Subject: Floating point exception in strtod()
$ cat strtod_test.c
#include <stdio.h>
#include <stdlib.h>
#include <fenv.h>
int
main ()
{
/* The following number comes from /usr/share/asymptote/ode.asy. */
const char *str = "121645100408832000.0";
char *ptr;
feenableexcept (FE_INVALID);
strtod (str, &ptr);
/* If there was an exception, the following will not get executed. */
printf ("No exception.\n");
}
$ gcc strtod_test.c
$ ./a
Floating point exception (core dumped)
[The above was on x86. On x86_64 there's simply no output.]
I have no idea what's special about the number 121645100408832000.0, but
the problem goes away if, for example, I replace the leading 1 by 2.
Ken
--
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