Indeed: I get false, false, true (LC 9 6 2 rc3).
Where we differ is in whether it's a bug, although I certainly agree it's inconsistent. The Wikipedia summary of the IEEE 754 standard says of NaN (the number):
Any comparison with NaN is treated as unordered.
which as I read it says that if you try to compare NaN the number with anything, all bets are off. I don't believe this is a LC issue - for instance in Tcl this happens
Code: Select all
$ tclsh
% expr NaN < NaN
0
% expr NaN == NaN
0
% expr NaN > NaN
0
%
and in C (note: I had to substitute "/" for "." in all code that follows because the forum software seems not to like dots that are embedded between other characters):
Code: Select all
#include <math/h>
#include <stdio/h>
int main() {
float mynan = nanf("abc");
printf("NaN < NaN: %d\n", (mynan < mynan));
printf("NaN == NaN: %d\n", (mynan == mynan));
printf("NaN > NaN: %d\n", (mynan > mynan));
}
compiled with
prints
Code: Select all
$ ./nantest
NaN < NaN: 0
NaN == NaN: 0
NaN > NaN: 0
$
Ok, how about Python?
Code: Select all
$ python3
Python 3/8/5 (default, Jan 27 2021, 15:41:15)
[GCC 9/3/0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> x = math/nan
>>> x < x
False
>>> x == x
False
>>> x < x
False
>>>
So I still think that the real issue is unwanted coercions when you're really after string comparisons. I'm only just learning LiveCode (though I was a user of HyperCard from when it first came out) and as far as I can see LC doesn't have a string comparison function like C's strcmp. That being so, to force string comparison when things can seem to be numbers you have to use this idiom (borrowed from shell programming) or something equivalent:
Code: Select all
put "INF" into bar
put "NAN" into foo
-- the wrong way...
put bar < foo
-- gives false because it's treating INF and NAN as numbers, which they are
-- but
put ("x" & bar) < ("x" & foo)
-- gives true because it forces string comparison