8000 [DOC] RDoc for Complex (#9260) · ruby/ruby@f907a71 · GitHub
[go: up one dir, main page]

Skip to content

Commit f907a71

Browse files
[DOC] RDoc for Complex (#9260)
1 parent 36b389c commit f907a71

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

complex.c

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,11 +1477,17 @@ nucomp_real_p_m(VALUE self)
14771477

14781478
/*
14791479
* call-seq:
1480-
* cmp.denominator -> integer
1480+
* denominator -> integer
14811481
*
1482-
* Returns the denominator (lcm of both denominator - real and imag).
1482+
* Returns the denominator of +self+, which is
1483+
* the {least common multiple}[https://en.wikipedia.org/wiki/Least_common_multiple]
1484+
* of <tt>self.real.denominator</tt> and <tt>self.imag.denominator</tt>:
14831485
*
1484-
* See numerator.
1486+
* Complex.rect(Rational(1, 2), Rational(2, 3)).denominator # => 6
1487+
*
1488+
* Note that <tt>n.denominator</tt> of a non-rational numeric is +1+.
1489+
*
1490+
* Related: Complex#numerator.
14851491
*/
14861492
static VALUE
14871493
nucomp_denominator(VALUE self)
@@ -1492,21 +1498,23 @@ nucomp_denominator(VALUE self)
14921498

14931499
/*
14941500
* call-seq:
1495-
* cmp.numerator -> numeric
1501+
* numerator -> new_complex
1502+
*
1503+
* Returns the \Complex object created from the numerators
1504+
* of the real and imaginary parts of +self+,
1505+
* after converting each part to the
1506+
* {lowest common denominator}[https://en.wikipedia.org/wiki/Lowest_common_denominator]
1507+
* of the two:
14961508
*
1497-
* Returns the numerator.
1509+
* c = Complex(Rational(2, 3), Rational(3, 4)) # => ((2/3)+(3/4)*i)
1510+
* c.numerator # => (8+9i)
14981511
*
1499-
* 1 2 3+4i <- numerator
1500-
* - + -i -> ----
1501-
* 2 3 6 <- denominator
1512+
* In this example, the lowest common denominator of the two parts is 12;
1513+
* the two converted parts may be thought of as \Complex(8, 12) and \Complex(9, 12),
1514+
* whose numerators, respectively, are 8 and 9;
1515+
* so the returned value of <tt>c.numerator</tt> is <tt>Complex(8, 9)</tt>.
15021516
*
1503-
* c = Complex('1/2+2/3i') #=> ((1/2)+(2/3)*i)
1504-
* n = c.numerator #=> (3+4i)
1505-
* d = c.denominator #=> 6
1506-
* n / d #=> ((1/2)+(2/3)*i)
1507-
* Complex(Rational(n.real, d), Rational(n.imag, d))
1508-
* #=> ((1/2)+(2/3)*i)
1509-
* See denominator.
1517+
* Related: Complex#denominator.
15101518
*/
15111519
static VALUE
15121520
nucomp_numerator(VALUE self)

0 commit comments

Comments
 (0)
0