Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-5640

Scala hash code of some Double objects is different when it is seen as Double and when it is seen as Any

    Details

      Description

      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 .

      def testHashHash {
        val d = (BigInt(1) << 64).toDouble
        val a: Any = d
        println("d.hashCode="+d.hashCode)
        println("d.##="+d.##)
        println("a.##="+a.##)
        assert(d.## == a.##)
      }
      

      This is because BoxesRunTime.hashFromDouble(java.lang.Double n) and ScalaRunTime.hash(dv: Double) don't match.

        Attachments

          Activity

            People

            • Assignee:
              extempore Paul Phillips
              Reporter:
              nadezhin Dmitry Nadezhin
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: