This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Floating point exception in strtod()
On Sat, Apr 07, 2018 at 04:56:13PM -0400, Eliot Moss wrote:
> 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
>
I tried in 64-bit with the same result as Eliot: works fine w/out
feenableexcept, no o/p with feenableexcept.
Cheers ... Duncan.
--
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