instance method
Complex#imag
() -> ::Numeric
imag → numeric
complex.c
View on GitHub ↗
VALUE
rb_complex_imag(VALUE self)
{
get_dat1(self);
return dat->imag;
}
Alias of #imaginary
Returns the imaginary value for self:
Example
Complex.rect(7).imag # => 0 Complex.rect(9, -4).imag # => -4
If self was created with polar coordinates, the returned value is computed, and may be inexact:
Example
Complex.polar(1, Math::PI/4).imag # => 0.7071067811865476 # Square root of 2.