Bug #14014
closedNaN.finite?
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
Updated by nobu (Nobuyoshi Nakada) about 7 years ago
- Status changed from Open to Rejected
NaN is not a (either infinite or finite) number, definitely.
Also it is not positive nor negative, so its signedness is nonsense too.
Complex(0/0.0, 0).finite?
returns false
in the trunk already.
Updated by Eregon (Benoit Daloze) about 7 years ago
Has this been backported to the 2.4 branch? I think it should.
What commit fixed it?
Updated by nobu (Nobuyoshi Nakada) about 7 years ago
Not yet, it's r60040.
Updated by marcandre (Marc-Andre Lafortune) about 7 years ago
Thanks, sorry I should have tested trunk.
Updated by Eregon (Benoit Daloze) about 7 years ago
Should this be marked as closed rather than rejected and a test be added for NaN for the backport to be performed then?
Updated by nobu (Nobuyoshi Nakada) about 7 years ago
- Status changed from Rejected to Closed
- Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN to 2.3: DONTNEED, 2.4: REQUIRED
Updated by nagachika (Tomoyuki Chikanaga) almost 7 years ago
- Backport changed from 2.3: DONTNEED, 2.4: REQUIRED to 2.3: DONTNEED, 2.4: DONE
ruby_2_4 r62173 merged revision(s) 60040,60188.