You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The BigInt.equals(that: Any) and BigDecimal.equals(that: Any) should implement
equality in mathematical sense (at least when "that" is primitive.
I mean that BigInt.equals(that: Any) iff "this" and "that" represent the same rational number.
However, this is not always so.
The value 2^64 can be represented exactly both by BigInt, Float and Double, but the assertions below fails.
I would like the same for equality between primitives too, but I understand
the burden of compatibility with fuzzy Java definition of operators
float == int
double == long
The text was updated successfully, but these errors were encountered:
@nadezhin said:
Sorry, I found now that this bug is duplicate of #4540 and it has been fixed already by overriding isValidChar/isValidByte/isValidShort in BigInt/BigDecimal .
Nevertheless, there is still an issue with comparison of BigInt/BigDecimal with Float/Double .
def testBigIntEquals {
val bi = BigInt(1) << 64;
assert(bi == bi.toFloat);
assert(bi == bi.toDouble)
}
This test fails, though 2^64 is represented exactly in both Float and Double.
If you agree that this is a bug, then I can try to prepare a pull request that fixes comparison of BigInt/BigDecimal with Float/Double .
The BigInt.equals(that: Any) and BigDecimal.equals(that: Any) should implement
equality in mathematical sense (at least when "that" is primitive.
I mean that BigInt.equals(that: Any) iff "this" and "that" represent the same rational number.
However, this is not always so.
The value 2^64 can be represented exactly both by BigInt, Float and Double, but the assertions below fails.
The value 2^53 + 1 doesn't equal to 2^53 but the assertions below fails too
I would like the same for equality between primitives too, but I understand
the burden of compatibility with fuzzy Java definition of operators
float == int
double == long
The text was updated successfully, but these errors were encountered: