-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
scala/scala
#8104Description
Scala's RichDouble
does not provide .isFinite
. If you want to make sure that a Double
is finite, you either have to write your own implementation by combining the negatives of .isNaN
and .isInfinity
, or fall back on java.lang.Double.isFinite(_)
.isFinite
- is on the same (or similar) level of abstraction as
.isNaN
and.isInfinity
, - is neither the inverse of
.isNaN
nor.isInfinity
(it's something else), - provides at least the same utility as
.isNaN
nor.isInfinity
Lastly at least in my judgement it's more common to ensure that a number is finite, than to ensure that a number is Infinity/NaN. In most cases Infinity/NaN is what you want a number not to be, and you end up using those methods for filtering purposes, where .isFinite
would provide the greater utility and readability. Using java.lang.Double
is ugly and reinventing the wheel (writing your own implementation) is unnecessary.
For the above reasons I propose to add .isFinite
to RichDouble
.