Web lists-archives.com

Re: Floating point exception in strtod()




On 4/7/2018 1:40 PM, Ken Brown wrote:
$ 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");
}

If I do the same thing WITHOUT the feenableexcept, it works fine.
Perhaps strtod catches an exception and then applies a different
method in some cases, or perhaps it wants exceptions off and
deals with things its own way.

If I include the feenableexcept, I get the same behavior you
reported (in 32-bit; I did not test 64-bit).

Regards - Eliot Moss

--
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