Skip to content

hashCode for floating points has a very bad distribution #1192

@gzm0

Description

@gzm0

We cannot implement hashCode for java.lang.{Float, Double} the way Java specifies, because these boxes equal the integral-value boxes if they itself contain the corresponding integer value.

Therefore, we must have:

new Double(4.0).hashCode == new Integer(4).hashCode

Currently we use _.toInt as hashCode but that arguably gives very bad distribution. We should consider using the implementations in BoxesRunTime.

Metadata

Metadata

Assignees

Labels

bugConfirmed bug. Needs to be fixed.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions