NetBSD-Bugs archive

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

Re: bin/53507: awk doesn't properly compare "numeric strings"



The following reply was made to PR bin/53507; it has been noted by GNATS.

From: Paul Goyette <paul%whooppee.com@localhost>
To: "K. Schreiner" <ks%ub.uni-mainz.de@localhost>
Cc: gnats-bugs%NetBSD.org@localhost, kre%NetBSD.org@localhost, gnats-admin%netbsd.org@localhost, 
    netbsd-bugs%netbsd.org@localhost
Subject: Re: bin/53507: awk doesn't properly compare "numeric strings"
Date: Thu, 9 Aug 2018 05:21:03 +0800 (+08)

 >> -4: awk 'BEGIN { max="80" ; for (i=0; i<max; i++) {print i}; exit}' | wc -l
 >       9
 > hm, why 9? Maybe counts 0 to 8?
 
 The string "8" is less than "80"
 
 >> -5: awk 'BEGIN { max="90" ; for (i=0; i<max; i++) {print i}; exit}' | wc -l
 >      90
 > And now? 90 is ok - or not?
 >
 > Seems that 1-8 are "special" and 9 is handled as expectet?
 
 And, since "9" is less than "90" it will increment i and continue until
 we compare "90" vs "90"
 
 
 +------------------+--------------------------+----------------------------+
 | Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:          |
 | (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com   |
 | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org |
 +------------------+--------------------------+----------------------------+
 


Home | Main Index | Thread Index | Old Index