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: Eli Zaretskii
Subject: Re: gawk number to string bug
Date: Sat, 24 Dec 2005 09:22:16 +0200

> Date: Fri, 23 Dec 2005 17:20:57 -0500
> From: "Andrew J. Schorr" <address@hidden>
> Cc: David Ellsworth <address@hidden>, address@hidden,
>       address@hidden, address@hidden
> 
> 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?

I think Awk's printf should produce the same result as printf from the
C library (I think I saw somewhere that this is how Awk's behavior is
defined for this case).  So I think your patch produces a wrong
behavior.

> 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

Yes, the patched behavior is clearly wrong here.

On a broader scale, I've been silently listening to this thread and
privately talking to the Gawk maintainer (having the privilege of
sitting with him in the same room during office hours ;-) for quite
some time.  This thread produced many ideas and quite a few patches
(some of the patches made me shiver with horror in sight of the
monstrosity of a solution offered for such a simple problem), but IMHO
it failed to produce 2 things: (1) the Gawk maintainer's agreement to
all those ideas and patches, and (2) references to some standard, such
as Posix, as to what should Gawk do in these situations.  To me, these
deficiencies makes this whole discussion a bit pointless.

Just my $0.02.




reply via email to

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