#543 deep-equal(NaN, NaN) = false

v8.7.3
closed
Michael Kay
5
2012-10-08
2006-06-18
Michael Kay
No

The deep-equal() function treats two NaN values as
not-equal, whereas the spec requires that they be
treated as equal.

Source fix: in net.sf.saxon.functions.DeepEqual,
replace the "else" branch at line 159 with:

                } else {
                    AtomicValue av1 =

((AtomicValue)item1).getPrimitiveValue();
AtomicValue av2 =
((AtomicValue)item2).getPrimitiveValue();
if (av1 instanceof NumericValue
&& ((NumericValue)av1).isNaN() &&
av2 instanceof
NumericValue && ((NumericValue)av2).isNaN()) {
// treat as equal, no action
} else if
(!collator.comparesEqual(item1, item2)) {
result = false;
reason = "atomic values at
position " + op1.position() + " differ";
break;
}
}

Test cases: K-SeqDeepEqualFunc-8|9|10|11 in XQTS

Discussion

  • Michael Kay
    Michael Kay
    2006-06-18

    Logged In: YES
    user_id=251681

    The "else" branch is actually at line 142 in the Saxon 8.7.3
    source.