Skip to content

Commit

Permalink
[bugfix] Fix comparison of INF and -INF values for xs:float and xs:do…
Browse files Browse the repository at this point in the history
…uble
  • Loading branch information
adamretter committed Dec 10, 2022
1 parent 842285c commit 2d68bc6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ public boolean isPositive() {
@Override
protected @Nullable IntSupplier createComparisonWith(final NumericValue other) {
final IntSupplier comparison;
if (other instanceof IntegerValue) {
if (isInfinite() && other.isInfinite() && isPositive() == other.isPositive()) {
comparison = () -> Constants.EQUAL;
} else if (other instanceof IntegerValue) {
comparison = () -> BigDecimal.valueOf(value).compareTo(new BigDecimal(((IntegerValue)other).value));
} else if (other instanceof DecimalValue) {
comparison = () -> BigDecimal.valueOf(value).compareTo(((DecimalValue)other).value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ public boolean isPositive() {
@Override
protected @Nullable IntSupplier createComparisonWith(final NumericValue other) {
final IntSupplier comparison;
if (other instanceof IntegerValue) {

if (isInfinite() && other.isInfinite() && isPositive() == other.isPositive()) {
comparison = () -> Constants.EQUAL;
} else if (other instanceof IntegerValue) {
comparison = () -> BigDecimal.valueOf(value).compareTo(new BigDecimal(((IntegerValue)other).value));
} else if (other instanceof DecimalValue) {
final BigDecimal promoted = new BigDecimal(Float.toString(value));
Expand Down

0 comments on commit 2d68bc6

Please sign in to comment.