## Bug #14014

### NaN.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

### Associated revisions

test_complex.rb: NaN Complex

- test/ruby/test_complex.rb (test_finite_p): assertions for NaN Complex. NaN is not an infinite nor a finite number. [ruby-core:83272] [Bug #14014]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

test_complex.rb: NaN Complex

- test/ruby/test_complex.rb (test_finite_p): assertions for NaN Complex. NaN is not an infinite nor a finite number. [ruby-core:83272] [Bug #14014]

test_complex.rb: NaN Complex

- test/ruby/test_complex.rb (test_finite_p): assertions for NaN Complex. NaN is not an infinite nor a finite number. [ruby-core:83272] [Bug #14014]

test_complex.rb: NaN Complex

merge revision(s) 60040,60188: [Backport #14014]

complex.c: no overflow * complex.c (rb_complex_finite_p): get rid of overflow and unnecessary multiplication. test_complex.rb: NaN Complex * test/ruby/test_complex.rb (test_finite_p): assertions for NaN Complex. NaN is not an infinite nor a finite number. [ruby-core:83272] [Bug #14014]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@62173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

merge revision(s) 60040,60188: [Backport #14014]

complex.c: no overflow * complex.c (rb_complex_finite_p): get rid of overflow and unnecessary multiplication. test_complex.rb: NaN Complex * test/ruby/test_complex.rb (test_finite_p): assertions for NaN Complex. NaN is not an infinite nor a finite number. [ruby-core:83272] [Bug #14014]

### History

#### Updated by nobu (Nobuyoshi Nakada) almost 2 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) almost 2 years ago

Has this been backported to the 2.4 branch? I think it should.

What commit fixed it?

#### Updated by marcandre (Marc-Andre Lafortune) almost 2 years ago

Thanks, sorry I should have tested trunk.

#### Updated by Eregon (Benoit Daloze) almost 2 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) almost 2 years ago

**Backport**changed from*2.3: UNKNOWN, 2.4: UNKNOWN*to*2.3: DONTNEED, 2.4: REQUIRED***Status**changed from*Rejected*to*Closed*

#### Updated by nagachika (Tomoyuki Chikanaga) over 1 year 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.

complex.c: no overflow