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

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

Re: Negative number comparisons in GAWK


From: tt
Subject: Re: Negative number comparisons in GAWK
Date: 21 Apr 2001 05:31:37 +0300

address@hidden (NIDE Naoyuki) writes:

> In article <address@hidden>,

> > This bug goes away when the comma is removed, and works properly.  If a
> > comma is directly at the end of the numeric value, it fails.
> > gawk ' { if ($1 < -1.0) {print} } ' inputfile >outputfile
> 
>   Read the 'Variable Typing And Conversion' section of gawk manual.
> Gawk performs a string comparison if one value is a non-numeric string.
> A string which contains ',' is not regarded as a numeric string.  You
> should remove ',' from the string data before comparison.

Or force numeric conversion, e.g.,

> > gawk ' { if (0+$1 < -1.0) {print} } ' inputfile >outputfile

-- 
Tapani Tarvainen



reply via email to

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