End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Complex#infinite?
cmp.infinite? → nil or 1
complex.c
View on GitHub ↗
static VALUE
rb_complex_infinite_p(VALUE self)
{
get_dat1(self);
if (NIL_P(f_infinite_p(dat->real)) && NIL_P(f_infinite_p(dat->imag))) {
return Qnil;
}
return ONE;
}
Returns 1 if cmp‘s real or imaginary part is an infinite number, otherwise returns nil.
Example
For example: (1+1i).infinite? #=> nil (Float::INFINITY + 1i).infinite? #=> 1