Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Complex#denominator
() -> ::Integer
denominator → integer
complex.c
View on GitHub ↗
static VALUE
nucomp_denominator(VALUE self)
{
get_dat1(self);
return rb_lcm(f_denominator(dat->real), f_denominator(dat->imag));
}
Returns the denominator of self, which is the least common multiple of self.real.denominator and self.imag.denominator:
Example
Complex.rect(Rational(1, 2), Rational(2, 3)).denominator # => 6
Note that n.denominator of a non-rational numeric is 1.
Related: Complex#numerator.