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: Mon, 26 Dec 2005 10:04:49 -0500
User-agent: Mutt/1.4.1i

On Sun, Dec 25, 2005 at 11:39:48AM -0800, Paul Eggert wrote:
>    8. For each conversion specification that consumes an argument, the
>    next expression argument shall be evaluated. With the exception of
>    the c conversion specifier character, the value shall be converted
>    (according to the rules specified in Expressions in awk) to the
>    appropriate type for the conversion specification.
> 
> Here, the appropriate type is integer, and the behavior is undefined
> if the numeric value is not an integer (i.e., doesn't fit in a finite
> range that is at least that of a 32-bit signed integer).  Hence, if
> the value is out of range, POSIX allows gawk to use "%.0f".  However,
> if the value is in range, "%.0f" should not be used if it produces
> results differing from "%d" (which can occur with -0.0, for example).
> 
> I was also worried about flag characters, e.g., the "0" in "%01d", but
> I guess if we use %.0f only for not-in-range values we should be OK.

Yes, I was also worried about flag characters.  So, if you look at the
actual patch I submitted, you will see that I am just using "%.0f"
to convert the value to digits, but then using the same logic as before
to render the value (i.e. I am just replacing the '0'+(uval % 10) logic
with grabbing a character from the sprintf "%.0f" output).

Regards,
Andy




reply via email to

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