Skip to content

NumericRange[Double].contains() doesn't work due to rounding errors #9874

@scabug

Description

@scabug

NumericRange is internally implemented by means of arithmetics - causing some trouble when working with doubles:

val r = 0.0 to 1.0 by 0.1
r.indexOf(r(3))  // => 3
r.contains(r(3)) // => false

Problem is that numeric range is a collection - really bad things can happen if someone passes NumericRange where Seq is expected and contains() method is used.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions