Skip to content

xpath BUGFIX comparison of NaN - #2669

Open
lamestllama wants to merge 1 commit into
CESNET:develfrom
lamestllama:fix/xpath-nan-comparison
Open

lamestllama wants to merge 1 commit into
CESNET:develfrom
lamestllama:fix/xpath-nan-comparison

Conversation

@lamestllama

Copy link
Copy Markdown

What

When either number is NaN, moveto_op_comp() now returns false for =, <, <=, >, >= and true for !=, before calling moveto_num_cmp(), so the #2519 precision fix is unchanged for other numbers.

Why

moveto_num_cmp() compares numbers as printed text, so NaN equals NaN and orders by its text. XPath 1.0 §3.4 compares numbers by IEEE 754, under which every comparison with NaN is false except !=.

Fixes #2667

Test

Six NaN cases in test_number; they fail before the fix, and all of ctest passes after it.

Numbers are compared as printed text to avoid precision issues, so
NaN, printed as "nan", was equal to itself and ordered against other
numbers by its text. XPath 1.0 section 3.4 compares numbers according
to IEEE 754, under which every comparison with NaN is false except
'!=', which is true.

Fixes CESNET#2667
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant