bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] gawk simple compare not working?


From: arnold
Subject: Re: [bug-gawk] gawk simple compare not working?
Date: Wed, 01 Apr 2015 00:21:48 -0600
User-agent: Heirloom mailx 12.4 7/29/08

Hi Mary.

Thanks for the note.

Andy's answer, including link, is right on target. You can use

        "" variable

to force a variable to be treated as a string, which is what you want.

If you use -M, you should probably specify a precision larger than
the default of 53 which is the same as for double precision hardware
floating point.

Thanks,

Arnold


"Andrew J. Schorr" <address@hidden> wrote:

> Hi,
>
> On Tue, Mar 31, 2015 at 05:08:08PM +0000, Dial, Mary wrote:
> > I'm stumped! Any help is appreciated.
> > 
> > I run this simple gawk compare program (below) and it does not return the 
> > correct answer. But if a append an 'x' to the compare, then it works. Im 
> > not sure if this is an gawk bug.
> > 
> > I'm using Red Hat Linux 6.6. Both gawk 3.7.1 and 4.1 return the same results
> > 
> > Here is the sample input where the 2nd to last characters are different
> > File c1
> > 073343000773200000000075
> > 
> > File c2
> > 073343000773200000000005
> > 
> > Here is the run test run
> > gawk_test_diff c1 c2
> > Straight Compare - Lines are the same
> > Add Char Compare - Lines are different
>
> I think this should explain it:
>
>    https://www.gnu.org/software/gawk/manual/html_node/Variable-Typing.html
>
> When a numeric comparison is used, there are overflow problems (both map to
> 73343000773200000843776 on my system).  String comparison should work fine.
> If you use the -M option, that may solve the numeric overflow issue.
>
> Regards,
> Andy



reply via email to

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