bug-gawk
[Top][All Lists]
Advanced

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

Re: gawk bug - 'is equal' is faulty for string


From: arnold
Subject: Re: gawk bug - 'is equal' is faulty for string
Date: Mon, 27 Jan 2020 08:12:13 -0700
User-agent: Heirloom mailx 12.5 7/5/10

Thanks everyone for the answers. It's nice to have other people
beat me to it.  Jerome, glad you're all set now.

Arnold

Jérôme Jargot <address@hidden> wrote:

> Haaa, of course!
>
> Thank you for your answers
>
> On Mon, Jan 27, 2020 at 3:42 PM Andrew J. Schorr <
> address@hidden> wrote:
>
> > On Mon, Jan 27, 2020 at 03:32:19PM +0100, Manuel Collado wrote:
> > > I think this is the expected result in both cases. The
> > > "$4==cversion" comparison is a numeric one, because both $4 and
> > > cversion values come from input data and look as numbers.
> > >
> > > Please search for "numeric string" or "strnum" in the gawk manual.
> >
> > Manuel is correct. You can force a string comparison by concatenating one
> > of
> > the operands with "", e.g. (y == x"").  The chart below from the
> > docs is useful for understanding how comparison works. And in newer
> > versions of gawk, the typeof function is useful for getting a better
> > understanding of what's going on.
> >
> > https://www.gnu.org/software/gawk/manual/html_node/Variable-Typing.html
> >
> >    When two operands are compared, either string comparison or numeric
> > comparison may be used.  This depends upon the attributes of the
> > operands, according to the following symmetric matrix:
> >
> >         +----------------------------------------------
> >         |       STRING          NUMERIC         STRNUM
> > --------+----------------------------------------------
> >         |
> > STRING  |       string          string          string
> >         |
> > NUMERIC |       string          numeric         numeric
> >         |
> > STRNUM  |       string          numeric         numeric
> > --------+----------------------------------------------
> >
> > Regards,
> > Andy
> >



reply via email to

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