This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Floating point exception in strtod()
- From: Dan Kegel <dank at kegel dot com>
- To: cygwin at cygwin dot com
- Date: Sat, 07 Apr 2018 20:52:01 +0000
- Subject: Re: Floating point exception in strtod()
- References: <dd5e98ea-8f39-1c4b-116c-37968cb3a52d@cornell.edu>
- Reply-to: dank at kegel dot com
Is that 19! ? Probably doesn't fit precisely into a double. Does strtold
behave better?
Some implementations throw on unrepresentable numbers, e.g.
https://docs.oracle.com/cd/E19253-01/816-5168/6mbb3hrte/index.html
Ken Brown <kbrown@cornell.edu> schrieb am Sa., 7. Apr. 2018, 10:40:
> $ 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
>
>
>
--
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