Skip to content

List(1.0, -1.0).sorted gives a deprecation warning #11844

Closed
scala/scala
#8721
@eed3si9n

Description

@eed3si9n

Originally posted by @odersky in #10511 (comment)

Ref scala/scala#6323
Ref scala/scala#6410

steps

scala> List(1.0, -1.0).sorted
warning: there was one deprecation warning (since 2.13.0); for details, enable `:setting -deprecation' or `:replay -deprecation'
res0: List[Double] = List(-1.0, 1.0)

problem

It gives a deprecation warning. I think this is very bad, not to say catastrophic.

expectation

These things should just work. I don't care what ordering is used and whether it is inconsistent or not (we all know IEEE is broken and unfixable). But we should do the right thing for everyday users. As an everyday user I do not care what the ordering does for NaN and -0.0, maybe I do not even know that these weird numbers exist! (and they should not exist, if I go by common mathematical logic). But I do care that I can sort a list of doubles without going into the deeper mysteries of Scala's implicit system. This requirement is now violated.

notes

I think we should revert ASAP. We should keep the old total ordering and offer IEEE as an optional alternative that needs to be imported explicitly.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions