-
Notifications
You must be signed in to change notification settings - Fork 22
ArraySeq.ofFloat/ofDouble have wrong equals behavior #13108
Copy link
Copy link
Closed
scala/scala
#11083Description
Reproduction steps
Scala version: 3.7.0 (but the bug is in the standard library)
scala> import scala.collection.immutable.ArraySeq
scala> ArraySeq(0.0f) == ArraySeq(-0.0f)
val res0: Boolean = false
scala> ArraySeq(0.0f).map(identity) == ArraySeq(-0.0f)
val res1: Boolean = trueProblem
ArraySeq equals should use == for floating point that follow IEEE semantics as done by Other Seqs.
The problem is that the specialization ofFloat and ofDouble delegate equals to java.util.Arrays.equals but that is documented to not follow the normal == behavior https://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html#equals-double:A-double:A-
Reactions are currently unavailable