8000 RichDouble(_).isFinite is missing · Issue #11531 · scala/bug · GitHub
[go: up one dir, main page]

Skip to content
RichDouble(_).isFinite is missing #11531
@otto-dev

Description

@otto-dev

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0