Project

General

Profile

Actions

Bug #14014

closed

NaN.finite?

Added by marcandre (Marc-Andre Lafortune) about 7 years ago. Updated almost 7 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
2.4.2
[ruby-core:83272]

Description

Ruby gives contradictory answers for NaN:

> (0/0.0).finite?
 => false 
> Complex(0/0.0, 0).finite?
 => true 

Note that (0/0.0).infinite? returns nil, so the float answer of false looks even more wrong.

The two solutions I see are either changing Float#finite? to return true for NaN, or to raise in both cases.

I'd lean towards raising in both cases, as NaN can not be said to be finite or infinite

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0