NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: port-sparc/44389
The following reply was made to PR port-sparc/44389; it has been noted by GNATS.
From: Mateusz Loskot <mateusz%loskot.net@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: Martin Husemann <martin%duskware.de@localhost>,
port-sparc-maintainer%netbsd.org@localhost, gnats-admin%netbsd.org@localhost,
netbsd-bugs%netbsd.org@localhost
Subject: Re: port-sparc/44389
Date: Tue, 18 Jan 2011 15:00:42 +0000
On 18/01/11 13:35, Martin Husemann wrote:
> The following reply was made to PR port-sparc/44389; it has been noted by
> GNATS.
>
> From: Martin Husemann<martin%duskware.de@localhost>
> To: gnats-bugs%NetBSD.org@localhost
> Cc:
> Subject: Re: port-sparc/44389
> Date: Tue, 18 Jan 2011 14:30:09 +0100
>
> Ok - last try - check the output of this one.
>
> Martin
>
> #include<stdio.h>
> #include<stdlib.h>
> #include<math.h>
> #include<errno.h>
>
> int is_number(const char *s)
> {
> double r;
> char *ep;
> errno = 0;
> r = strtod(s,&ep);
> if (ep == s || r == HUGE_VAL || errno == ERANGE)
> return 0;
> while (*ep == ' ' || *ep == '\t' || *ep == '\n')
> ep++;
> if (*ep == '\0')
> return 1;
> else
> return 0;
> }
>
> int main(int argc, char **argv)
> {
> double v;
>
> if (is_number("NaN")) {
> printf("is a number\n");
> v = atof("NaN");
> } else {
> printf("not a number\n");
> v = 0.0;
> }
> printf("%.4f\n", v);
>
> return 0;
> }
This one receive SIGFPE:
$ gcc ./nan_test_2.c
$ ./a.out
[1] Floating point exception (core dumped) ./a.out
Specifically, it's caused by r == HUGE_VAL condition in
if (ep == s || r == HUGE_VAL || errno == ERANGE)
Though, not sure about conclusion.
--
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org
Member of ACCU, http://accu.org
Home |
Main Index |
Thread Index |
Old Index