[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Special Comparisons: nan == nan
From: |
Andrew J. Schorr |
Subject: |
Re: [bug-gawk] Special Comparisons: nan == nan |
Date: |
Mon, 7 Aug 2017 19:25:24 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hi,
On Mon, Aug 07, 2017 at 03:11:36PM -0700, Daniel Pettet wrote:
> Thanks for the prompt replies. I think gawk had this one right several
> versions back.
What version might that be? The quick exit in eval.c:cmp_nodes has been
there since the beginning, but perhaps you are thinking of a different
case where you are comparing two different variables.
The node.c:cmp_awknums logic with the special treatment of NaNs
dates to 2012-03-19. Using gawk-4.0.0, I see this:
bash-4.2$ ./gawk '
> BEGIN {
> nan = 0 * 1e400
> print nan # nan
> print nan == nan # 1 should be 0
> }
> '
-nan
1
But this works as you'd prefer:
bash-4.2$ ./gawk '
> BEGIN {
> nan = 0 * 1e400
> nan2 = nan-1
> print nan, nan2 # nan
> print nan == nan2 # 1 should be 0
> }
> '
-nan -nan
0
By gawk-4.1.0, the second case was also indicating equality:
bash-4.2$ ./gawk '
> BEGIN {
> nan = 0 * 1e400
> nan2 = nan-1
> print nan, nan2 # nan
> print nan == nan2 # 1 should be 0
> }
> '
-nan -nan
1
Regards,
Andy
Re: [bug-gawk] Special Comparisons: uninitialized array index, Andrew J. Schorr, 2017/08/07
- Re: [bug-gawk] Special Comparisons: uninitialized array index, Andrew J. Schorr, 2017/08/07
- Re: [bug-gawk] Special Comparisons: uninitialized array index, Andrew J. Schorr, 2017/08/07
- Re: [bug-gawk] Special Comparisons: uninitialized array index, arnold, 2017/08/07
- Re: [bug-gawk] Special Comparisons: uninitialized array index, Andrew J. Schorr, 2017/08/07
- Re: [bug-gawk] Special Comparisons: uninitialized array index, arnold, 2017/08/08
- Re: [bug-gawk] Special Comparisons: uninitialized array index, arnold, 2017/08/10