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: Eli Zaretskii
Subject: Re: [bug-gawk] Overflow to Infinity
Date: Fri, 06 Jul 2018 15:31:03 +0300

> Date: Fri, 6 Jul 2018 05:35:03 -0400
> From: "Andrew J. Schorr" <address@hidden>
> Cc: Arnold Robbins <address@hidden>, address@hidden,
>       address@hidden
> 
> > Why do you need to sprintf the value, if it is known that it's a NaN?
> > Why not do what you do with Inf:
> > 
> > > + } else if (isinf(val)) {
> > > +         strcpy(buf, val < 0 ? "-inf" : "+inf");
> 
> 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?

The sign bit is accessible, isn't it?

> Perhaps this would work:
> 
> 
> +     if (isnan(val)) {
> +             sprintf(buf, "%g", val);
> +             strcpy(buf, buf[0] == '-' ? "-nan" : "+nan");

That could also work, yes.  It's more expensive, but maybe we don't
care in this case.



reply via email to

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