This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Floating point exception in strtod()
- From: Eliot Moss <moss at cs dot umass dot edu>
- To: cygwin at cygwin dot com
- Date: Sat, 7 Apr 2018 16:56:13 -0400
- Subject: Re: Floating point exception in strtod()
- References: <dd5e98ea-8f39-1c4b-116c-37968cb3a52d@cornell.edu>
- Reply-to: moss at cs dot umass dot edu
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