Skip to content

Commit

Permalink
[DOC] RDoc for Complex (#9260)
Browse files Browse the repository at this point in the history
  • Loading branch information
BurdetteLamar committed Dec 19, 2023
1 parent 36b389c commit f907a71
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions complex.c
Expand Up @@ -1477,11 +1477,17 @@ nucomp_real_p_m(VALUE self)

/*
* call-seq:
* cmp.denominator -> integer
* denominator -> integer
*
* Returns the denominator (lcm of both denominator - real and imag).
* Returns the denominator of +self+, which is
* the {least common multiple}[https://en.wikipedia.org/wiki/Least_common_multiple]
* of <tt>self.real.denominator</tt> and <tt>self.imag.denominator</tt>:
*
* See numerator.
* Complex.rect(Rational(1, 2), Rational(2, 3)).denominator # => 6
*
* Note that <tt>n.denominator</tt> of a non-rational numeric is +1+.
*
* Related: Complex#numerator.
*/
static VALUE
nucomp_denominator(VALUE self)
Expand All @@ -1492,21 +1498,23 @@ nucomp_denominator(VALUE self)

/*
* call-seq:
* cmp.numerator -> numeric
* numerator -> new_complex
*
* Returns the \Complex object created from the numerators
* of the real and imaginary parts of +self+,
* after converting each part to the
* {lowest common denominator}[https://en.wikipedia.org/wiki/Lowest_common_denominator]
* of the two:
*
* Returns the numerator.
* c = Complex(Rational(2, 3), Rational(3, 4)) # => ((2/3)+(3/4)*i)
* c.numerator # => (8+9i)
*
* 1 2 3+4i <- numerator
* - + -i -> ----
* 2 3 6 <- denominator
* In this example, the lowest common denominator of the two parts is 12;
* the two converted parts may be thought of as \Complex(8, 12) and \Complex(9, 12),
* whose numerators, respectively, are 8 and 9;
* so the returned value of <tt>c.numerator</tt> is <tt>Complex(8, 9)</tt>.
*
* 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.
* Related: Complex#denominator.
*/
static VALUE
nucomp_numerator(VALUE self)
Expand Down

0 comments on commit f907a71

Please sign in to comment.