Skip to content

Commit

Permalink
[bugfix] Fix comparison of NaN values for xs:float and xs:double
Browse files Browse the repository at this point in the history
  • Loading branch information
adamretter committed Dec 10, 2022
1 parent 2d68bc6 commit 185ee37
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ public boolean isPositive() {
@Override
protected @Nullable IntSupplier createComparisonWith(final NumericValue other) {
final IntSupplier comparison;
if (isInfinite() && other.isInfinite() && isPositive() == other.isPositive()) {
if (isNaN()) {
comparison = () -> Constants.INFERIOR;
} else if (other.isNaN()) {
comparison = () -> Constants.SUPERIOR;
} else 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,11 @@ public boolean isPositive() {
@Override
protected @Nullable IntSupplier createComparisonWith(final NumericValue other) {
final IntSupplier comparison;

if (isInfinite() && other.isInfinite() && isPositive() == other.isPositive()) {
if (isNaN()) {
comparison = () -> Constants.INFERIOR;
} else if (other.isNaN()) {
comparison = () -> Constants.SUPERIOR;
} else 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));
Expand Down

0 comments on commit 185ee37

Please sign in to comment.