numerator

cmp.numerator â numeric
Instance Public methods

Returns the numerator.

1
2
3
4
5
6
7
8
9
10
    1   2       3+4i  <-  numerator
    - + -i  ->  ----
    2   3        6    <-  denominator
 
c = Complex('1/2+2/3i'#=> ((1/2)+(2/3)*i)
n = c.numerator          #=> (3+4i)
d = c.denominator        #=> 6
n / d                    #=> ((1/2)+(2/3)*i)
Complex(Rational(n.real, d), Rational(n.imag, d))
                         #=> ((1/2)+(2/3)*i)

See denominator.

doc_ruby_on_rails
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.