[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Negative number comparisons in GAWK
From: |
Aharon Robbins |
Subject: |
Re: Negative number comparisons in GAWK |
Date: |
Mon, 23 Apr 2001 10:42:36 +0300 |
Hi. As pointed out in several answers already, gawk is behaving
as it's supposed to. The best way to get what you want is
gawk '{ if ($1 + 0 < -1.0) print }' infile > outfile
Thanks,
Arnold Robbins
> From: Kevin Hass <address@hidden>
> Subject: Negative number comparisons in GAWK
> To: address@hidden
> Date: Thu, 19 Apr 2001 15:35:00 -0600 (MDT)
> Cc: address@hidden
>
> Hi,
>
> I have found a bug in gawk 3.0.6.
>
> I'm using the Slackware 7.1 version of Linux distribution, and the
> gawk came with the distribution.
>
> (assuming it was built with the same compiler in the distribution..)
> gcc version egcs-2.91.66
> libc 2.1.3.so
>
> The nature of the bug:
>
> 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.
>
> The script used:
> gawk ' { if ($1 < -1.0) {print} } ' inputfile >outputfile
>
>
> Kevin
> --
> Kevin Hass WB0DPN Transportation Technology Center, Inc
> Senior Systems Programmer Pueblo, CO, USA
> (719)-584-0596
> address@hidden