|
From: | Daniel Pettet |
Subject: | Re: [bug-gawk] Special Comparisons: nan == nan |
Date: | Mon, 7 Aug 2017 17:10:08 -0700 |
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
[Prev in Thread] | Current Thread | [Next in Thread] |