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
Scala hash code of some Double objects is different when it is seen as Double and when it is seen as Any #5640
Comments
Imported From: https://issues.scala-lang.org/browse/SI-5640?orig=1 |
@magarciaEPFL said:
|
@dgruntz said: scala> val d = (BigInt(1) << 64).toDouble
d: Double = 1.8446744073709552E19
scala> val a: Any = d
a: Any = 1.8446744073709552E19
scala> d.hashCode
res22: Int = 1139802112
scala> a.hashCode
res23: Int = 1139802112 So if this behavior is changed, do not forget to update the docs of |
@paulp said (edited on May 8, 2012 10:50:50 PM UTC):
|
@paulp said: |
@paulp said: |
@dgruntz said: scala> runtime.BoxesRunTime.hashFromNumber(d)
res16: Int = 1139802112
scala> runtime.BoxesRunTime.hashFromNumber(d.toFloat)
res17: Int = 1602224128
scala> d == d.toFloat
res18: Boolean = true |
@paulp said: |
@dgruntz said: |
The same object d below has different scala hash code
when it is seen as static type Double and when it is seen as static type Any .
This is because BoxesRunTime.hashFromDouble(java.lang.Double n) and ScalaRunTime.hash(dv: Double) don't match.
The text was updated successfully, but these errors were encountered: