[Top][All Lists]
[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: |
Sun, 25 Dec 2005 10:33:35 -0500 |
User-agent: |
Mutt/1.4.1i |
On Sun, Dec 25, 2005 at 08:19:59AM +0200, Eli Zaretskii wrote:
> > From: =?UTF-8?B?SsO8cmdlbiBLYWhycw==?=
> > <address@hidden>
> > Date: Sat, 24 Dec 2005 21:35:32 +0100
> > Cc:
> >
> > Here is an old version which is still online:
> >
> > http://www.opengroup.org/onlinepubs/007908799/xcu/awk.html
>
> Thanks. This says that printf should behave as it does in C, with
> minor exceptions (which, AFAICS, are not relevant to this thread). It
> also says that integral values should be output as if formatted with
> %d, so %.0f is not a good idea, I think.
There is a newer version of the spec here:
http://www.opengroup.org/onlinepubs/009695399/utilities/awk.html
Also, in my opinion, this language:
A numeric value that is exactly equal to the value of an integer (see
Concepts Derived from the ISO C Standard) shall be converted to a string by
the equivalent of a call to the sprintf function (see String Functions) with
the string "%d" as the fmt argument and the numeric value being converted as
the first and only expr argument.
refers to the situation where a numeric (integer) value is being
converted to a string (perhaps by print, printf "%s", or by context).
I do not believe it refers to the explicit case where it is passed
as an argument to printf (or sprintf) "%d". (Note that it is
discussing general conversion to a string, not explicit printf
formatting with "%d").
Anyway, I still do not see anything that addresses how to format
a numeric value with "%d" when the numeric value overflows the
standard integer type. I still think that using "%.0f" in
this case gives more predictable and consistent behavior than
falling back to "%g" (with a possible warning message if --lint
is enabled).
Regards,
Andy
- Re: gawk number to string bug, (continued)
- Re: gawk number to string bug, Andrew J. Schorr, 2005/12/23
- Re: gawk number to string bug, Andrew J. Schorr, 2005/12/23
- Re: gawk number to string bug, Andrew J. Schorr, 2005/12/23
- Re: gawk number to string bug, Eli Zaretskii, 2005/12/24
- Re: gawk number to string bug, Andrew J. Schorr, 2005/12/24
- Re: gawk number to string bug, Eli Zaretskii, 2005/12/24
- Re: gawk number to string bug, Paul Jarc, 2005/12/24
- Re: gawk number to string bug, Paul Eggert, 2005/12/25
- Message not available
- Re: gawk number to string bug, Jürgen Kahrs, 2005/12/24
- Re: gawk number to string bug, Eli Zaretskii, 2005/12/25
- Re: gawk number to string bug,
Andrew J. Schorr <=
- Re: gawk number to string bug, Paul Eggert, 2005/12/25
- Re: gawk number to string bug, Andrew J. Schorr, 2005/12/26
- Message not available
- Re: gawk number to string bug, Jürgen Kahrs, 2005/12/22
Re: gawk number to string bug, Aharon Robbins, 2005/12/24
- Re: gawk number to string bug, Andrew J. Schorr, 2005/12/26
- Re: gawk number to string bug, Paul Eggert, 2005/12/26
- Re: gawk number to string bug, Andrew J. Schorr, 2005/12/26
- Re: gawk number to string bug, Andrew J. Schorr, 2005/12/27
- Re: gawk number to string bug, Andrew J. Schorr, 2005/12/28
- Re: gawk number to string bug, Andrew J. Schorr, 2005/12/28