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: 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;
 }
 
 


Home | Main Index | Thread Index | Old Index