bug-gnu-utils
[Top][All Lists]
Advanced

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

Error in number comparison


From: John Phillips
Subject: Error in number comparison
Date: Thu, 23 May 2002 15:38:21 +0900

I have a strange problem with Gawk.
Prepending a zero to a number makes it unequal to the original number,
except for single digit numbers.

I think this didn't used to happen. I have a makefile which relies on
a comparison of this type and which used to work but doesn't any more.
I have recently installed Linux version 7.2. Perhaps this has a newer
version of Gawk than I used to be using.

The following shows the problem:

address@hidden parse]$ uname -a
Linux john 2.4.9-13smp #1 SMP Tue Oct 30 19:57:16 EST 2001 i686 unknown
address@hidden parse]$ awk --version
GNU Awk 3.1.0
address@hidden parse]$ echo x | awk '01 == 1 {print "yes"}'
yes
address@hidden parse]$ echo x | awk '010 == 10 {print "yes"}'
address@hidden parse]$ echo x | awk '0+01 == 0+1 {print "yes"}'
yes
address@hidden parse]$ echo x | awk '0+010 == 0+10 {print "yes"}'
address@hidden parse]$ awk 'BEGIN { if ( 01==1 ) print "yes" }'
yes
address@hidden parse]$ awk 'BEGIN { if ( 010==10 ) print "yes" }'
address@hidden parse]$ 


Thank you
John Phillips
Dept of Linguistics
Yamaguchi University



reply via email to

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