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: Fri, 23 Dec 2005 17:20:57 -0500
User-agent: Mutt/1.4.1i

I thought of another issue.  Currently, gawk has the following behavior:

   $ gawk 'BEGIN {printf "%d\n",-.4}'
   -0

And this behavior is the same with the patch I just sent.
But my patch differs for this case:

   $ ./gawk 'BEGIN {printf "%d\n",-0.0}'
   -0

Versus standard (unpatched) gawk:

   $ gawk 'BEGIN {printf "%d\n",-0.0}'
   0

Is it clear what the proper behavior should be in such cases?  Is it
well defined?  It seems like a regression test could be useful to
cover this issue...

Also, there are rounding differences between my current patch and
standard gawk:

   Unpatched:
   $ gawk 'BEGIN {printf "%d\n",-.9}'
   -0

   Patched:
   $ ./gawk 'BEGIN {printf "%d\n",-.9}'
   -1

So do we need to truncate before calling snprintf("%.0f")?  Is it well-defined
what happens when a non-integral value is printed using "%d" in gawk?

Regards,
Andy




reply via email to

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