-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
866 Introduce and exploit new numeric-compare() function #881
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #866 (comment) for the idea to extend fn:compare
and drop fn:atomic-equal
(and fn:numeric-compare
).
If we add fn:numeric-compare
, we should probably move it from “4.3 Comparison operators on numeric values” to “4.4 Functions on numeric values”.
If we generalize fn:compare
, it needs to be moved from “5.3 Comparison of strings” to possibly “14.2 Comparison functions” (which includes fn:atomic-equal
).
The CG agreed to accept this PR at meeting 058 |
@michaelhkay The only edit I would propose before merging the PR is to move |
In addition, as @Arithmeticus indicated, we’ll need to define how
|
I have updated the PR:
|
16ead4d
to
031e40a
Compare
The CG agreed to merge this PR without discussion at meeting 59. |
Fix #866
The proposal introduces a new fn:numeric-compare function that differs from lt/eq primarily in that decimals are compared retaining their full precision, rather than converting them to doubles which may lose precision. This makes the comparison fully transitive which makes it safe to use in all sorting algorithms.
The new comparison semantics are exploited in max(), min(), and sort(), and indirectly in highest() and lowest(); they are also referenced for comparing numeric values in XSLT
xsl:sort
(and therefore indirectly inxsl:merge
) and in XQueryorder by
.An effect of the change is that max() and min() applied to a sequence of integers now return an integer, not a double.