bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: gawk number to string bug


From: Andrew J. Schorr
Subject: Re: gawk number to string bug
Date: Wed, 28 Dec 2005 15:00:56 -0500
User-agent: Mutt/1.4.1i

On Wed, Dec 28, 2005 at 02:30:07PM -0500, Andrew J. Schorr wrote:
> On Wed, Dec 28, 2005 at 09:09:21PM +0200, Eli Zaretskii wrote:
> > Try
> > 
> >     if (x != x)
> >     {
> >       /* this is not a finite number */
> >     }
> > 
> > (You need to make sure the compiler doesn't optimize away this
> > condition.)
> 
> In my testing, that works fine for NaN, but it does not catch Inf.

It seems that if (2*x == x) catches Inf or -Inf.  So one could perhaps
say:

  case 'd':
    ...
    if ((tmpval != tmpval) || (2*tmpval == tmpval))
      goto out_of_range;

Regards,
Andy




reply via email to

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