[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gawk: Locale-dependant bug with string to floating point conversion
From: |
Aharon Robbins |
Subject: |
Re: gawk: Locale-dependant bug with string to floating point conversion |
Date: |
Mon, 3 May 2004 14:25:25 +0300 |
Very well. One can certainly interpret the standard as you've done.
In my humble opinion that's a mistake in the standard, and I will not
make gawk accept hexadecimal input data by default. There's already a
runtime option for that. It happens that gawk currently allows hex and
octal constants in the source code, and disables them with the --posix
option, and I believe that continues to be the correct behavior.
A request for clarification should be filed, since I can't believe that
they purposely intended to allow hexadecimal floating point numbers. I
believe the intent was simply to disallow numbers like this
10.4F
Arnold
> To: Aharon Robbins <address@hidden>
> Cc: address@hidden, address@hidden, address@hidden,
> address@hidden
> Subject: Re: gawk: Locale-dependant bug with string to floating point
> conversion
> From: Paul Eggert <address@hidden>
> Date: Sun, 02 May 2004 20:22:54 -0700
>
> Aharon Robbins <address@hidden> writes:
>
> > Paul, it would help if you'd actually read the rest of that item:
>
> I did. You're correct in that the rest of that item makes it clear
> that all integer-constants are decimal, because of (1), (2), and (3)
> (quoted again below). However, there's only one restriction about
> floating-constants, namely (4), and this restriction does not outlaw
> hexadecimal floating-constants. Therefore, the 2004 POSIX awk spec
> requires support for hexadecimal floating-constants.
>
> Here's the chapter and verse again, for your convenience.
>
> The token NUMBER shall represent a numeric constant. Its form and numeric
> value shall be equivalent to either of the tokens floating-constant or
> integer-constant as specified by the ISO C standard, with the following
> exceptions:
>
> 1. An integer constant cannot begin with 0x or include the hexadecimal
> digits 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'A' , 'B' , 'C' , 'D' ,
> 'E' , or 'F' .
>
> 2. The value of an integer constant beginning with 0 shall be taken in
> decimal rather than octal.
>
> 3. An integer constant cannot include a suffix ( 'u' , 'U' , 'l' ,
> or 'L' ).
>
> 4. A floating constant cannot include a suffix ( 'f' , 'F' , 'l' ,
> or 'L' ).
>
> If the value is too large or too small to be representable (see Concepts
> Derived from the ISO C Standard ), the behavior is undefined.