[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Negative number comparisons in GAWK
From: |
NIDE Naoyuki |
Subject: |
Re: Negative number comparisons in GAWK |
Date: |
20 Apr 2001 03:04:33 GMT |
In article <address@hidden>,
address@hidden writes:
> I have some numeric data, which is also comma delimitted. I was using
> gawk to print only the values less than -1.0, but it prints the values
> between -1.0 and 0.0 instead. These numbers are real numbers, not integers.
> 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.
address@hidden