Repository navigation
xpath BUGFIX comparison of NaN - #2669
Open
lamestllama wants to merge 1 commit into
Open
lamestllama wants to merge 1 commit into
lamestllama wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When either number is NaN,
moveto_op_comp()now returns false for=,<,<=,>,>=and true for!=, before callingmoveto_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 ofctestpasses after it.