NaN ne NaN is false
The Saxon XSLT and XQuery processor, developed by Saxonica
Brought to you by:
mhkay
The result of the comparison (NaN ne NaN) should be
true, but is currently false. The same problem occurs
if the != operator is used.
Source fix: in ValueComparison.java, method compare(),
line 500, change
if (v1 instanceof NumericValue &&
((NumericValue)v1).isNaN()) {
return false;
}
to:
if (v1 instanceof NumericValue &&
((NumericValue)v1).isNaN()) {
if (op == Token.FNE && v2 instanceof
NumericValue && ((NumericValue)v2).isNaN()) {
return true;
}
return false;
}
Logged In: YES
user_id=251681
Correction to fix. The previous fix does not cover all
cases. The rule is that if either operand of "ne" or "!=" is
NaN, the result is true. So the code at the start of the
compare() method should be changed from:
if (v1 instanceof NumericValue && ((NumericValue)v1).isNaN()) {
return false;
}
if (v2 instanceof NumericValue &&
((NumericValue)v2).isNaN()) {
return false;
}
to:
if (v1 instanceof NumericValue && ((NumericValue)v1).isNaN()) {
return (op == Token.FNE);
}
if (v2 instanceof NumericValue &&
((NumericValue)v2).isNaN()) {
return (op == Token.FNE);
}