[Top][All Lists]

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

Re: gawk infinity issues

From: Andrew J. Schorr
Subject: Re: gawk infinity issues
Date: Fri, 6 Jan 2006 09:51:34 -0500
User-agent: Mutt/1.4.1i

On Fri, Jan 06, 2006 at 05:53:14AM +0200, Aharon Robbins wrote:
> Hi All.  This case is definitely one to leave as "not nailed down". There
> are too many systems, with too many variations in the underlying
> libraries, for gawk to be able to (easily) do something that is portable,
> works everywhere, and is maintainable.

The Open Group awk specification at 



   A string value shall be converted to a numeric value by the equivalent of
   the following calls to functions defined by the ISO C standard:

   setlocale(LC_NUMERIC, "");
   numeric_value = atof(string_value);

And in section of the ISO C99 spec, it says:

   double atof(const char *nptr);

   The atof function converts the initial portion of the string pointed to by
   nptr to double representation. Except for the behavior on error, it is
   equivalent to strtod(nptr, (char **)NULL)
And in section of the C99 spec, it defines strtod behavior.
It says (in part), that the expected form of the string includes:

    -- one of INF or INFINITY, ignoring case
    -- one of NAN or NAN(n-char-sequenceopt), ignoring case in the NAN part

This seems pretty clear to me.  And the glibc atof() function certainly
understands "inf" and "infinity" and "nan" on my linux platform (as well as
signed variations with "-" in front; and glibc strtod does not seem to be case
sensitive).  But gawk does not recognize these values.

So it seems to me that gawk currently violates the spec.  Or is there
some other more definitive spec out there?


reply via email to

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