Skip to content

Commit

Permalink
[bugfix] Further fixes to comparison of INF and -INF values for xs:fl…
Browse files Browse the repository at this point in the history
…oat and xs:double (XQTS: prod-OrderByClause)
  • Loading branch information
adamretter committed Sep 3, 2022
1 parent ff80f35 commit 87d963d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions exist-core/src/main/java/org/exist/xquery/value/DoubleValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,16 @@ public boolean isPositive() {
comparison = () -> Constants.INFERIOR;
} else if (other.isNaN()) {
comparison = () -> Constants.SUPERIOR;
} else if (isInfinite() && other.isInfinite() && isPositive() == other.isPositive()) {
comparison = () -> Constants.EQUAL;
} else if (isPositiveInfinity()) {
// +INF
comparison = () -> other.isPositiveInfinity() ? Constants.EQUAL : Constants.SUPERIOR;
} else if (other.isPositiveInfinity()) {
comparison = () -> Constants.INFERIOR;
} else if (isNegativeInfinity()) {
// -INF
comparison = () -> other.isNegativeInfinity() ? Constants.EQUAL : Constants.INFERIOR;
} else if (other.isNegativeInfinity()) {
comparison = () -> Constants.SUPERIOR;
} else if (other instanceof IntegerValue) {
comparison = () -> BigDecimal.valueOf(value).compareTo(new BigDecimal(((IntegerValue)other).value));
} else if (other instanceof DecimalValue) {
Expand Down
12 changes: 10 additions & 2 deletions exist-core/src/main/java/org/exist/xquery/value/FloatValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,16 @@ public boolean isPositive() {
comparison = () -> Constants.INFERIOR;
} else if (other.isNaN()) {
comparison = () -> Constants.SUPERIOR;
} else if (isInfinite() && other.isInfinite() && isPositive() == other.isPositive()) {
comparison = () -> Constants.EQUAL;
} else if (isPositiveInfinity()) {
// +INF
comparison = () -> other.isPositiveInfinity() ? Constants.EQUAL : Constants.SUPERIOR;
} else if (other.isPositiveInfinity()) {
comparison = () -> Constants.INFERIOR;
} else if (isNegativeInfinity()) {
// -INF
comparison = () -> other.isNegativeInfinity() ? Constants.EQUAL : Constants.INFERIOR;
} else if (other.isNegativeInfinity()) {
comparison = () -> Constants.SUPERIOR;
} else if (other instanceof IntegerValue) {
comparison = () -> BigDecimal.valueOf(value).compareTo(new BigDecimal(((IntegerValue)other).value));
} else if (other instanceof DecimalValue) {
Expand Down

0 comments on commit 87d963d

Please sign in to comment.