bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] Overflow to Infinity


From: arnold
Subject: Re: [bug-gawk] Overflow to Infinity
Date: Fri, 06 Jul 2018 05:51:53 -0600
User-agent: Heirloom mailx 12.4 7/29/08

"Andrew J. Schorr" <address@hidden> wrote:

> I don't think you get a different result when comparing +nan or -nan to 0,
> do you? Is there a way to test for NaN signedness?
> Perhaps this would work:
>
>
> +     if (isnan(val)) {
> +             sprintf(buf, "%g", val);
> +             strcpy(buf, buf[0] == '-' ? "-nan" : "+nan");

Well, I was relying on current sprintf behavior to produce -nan, which
is why I checked for "nan".

> But it seems like there ought to be a math library function to do this.
> After all, sprintf figures out the sign somehow. Does the 'signbit'
> function work with NaN values?

That's a new one on me. According to the man page, it should work on
NaNs and infinities.

Eli - does Windows support the signbit function? That would give us
a portable solution.

Thanks,

Arnold



reply via email to

[Prev in Thread] Current Thread [Next in Thread]