Re: msys 1.0.13 gawk problem

Charles Wilson <[email protected]>
Newsgroups gmane.comp.gnu.mingw.msys
Message-ID <[email protected]>
Ralf Fassel wrote:
> Bug: wrong values printed (should be -1 2 in both cases):
>     $  echo -1 2 | gawk '{printf "%g %g\n", $1, $2}'
>     1 -2
> 
>     $  echo -1 2 | gawk '{printf "%f %f\n", $1, $2}'
>     1.000000 -2.000000

>     $ gawk --version
>     Use -h to see help about each section
>     GNU Awk 3.1.7
>     Copyright (C) 1989, 1991-2009 Free Software Foundation.
> 
> - Same awk version on linux doesn't have this problem.
> - Msys 1.0.11 doesn't have this problem.
> 
> Can anyone confirm this?

I can confirm the behavior on msys, but not that it works any
differently anywhere else:

msys:
$ uname -s -r
MINGW32_NT-6.0 1.0.13(0.47/3/2)
$ gawk --version
GNU Awk 3.1.7
$ echo "-1 2" | gawk '{printf "%f %f\n", $1, $2}'
-1.000000 2.000000

linux:
$ uname -s -r
Linux 2.6.31.6-desktop-1mnb
$ gawk --version
GNU Awk 3.1.7
$ echo "-1 2" | gawk '{printf "%f %f\n", $1, $2}'
-1.000000 2.000000

$ uname -s -r
CYGWIN_NT-6.0 1.7.1(0.218/5/3)
$ gawk --version
GNU Awk 3.1.7
$ echo "-1 2" | gawk '{printf "%f %f\n", $1, $2}'
-1.000000 2.000000

My hunch is that msys-1.0.11 had a bug, or there was a problem in an
older version of gawk.  I really wouldn't expect gawk's %f printf to act
any differently that C's:

#include <stdio.h>
int main(int argc, char *argv[])
{
	double d1 = -1;
	double d2 = 2;
	printf ("%f %f\n", d1, d2);
}


$ gcc -o bob bob.c
$ ./bob
-1.000000 2.000000

--
Chuck

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.