Web lists-archives.com

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