Fwd: Floating point exception in strtod()

Ken Brown kbrown@cornell.edu
Sat Apr 7 17:46:00 GMT 2018


I just sent this to the cygwin list, but it probably belongs here.


-------- Forwarded Message --------
Subject: Floating point exception in strtod()
Resent-From: kbrown@cornell.edu
Date: Sat, 7 Apr 2018 13:40:05 -0400
From: Ken Brown <kbrown@cornell.edu>
To: cygwin <cygwin@cygwin.com>

$ 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


-- 
!<symlink>ÿþ/



More information about the Newlib mailing list