summaryrefslogtreecommitdiff
path: root/complex.c
diff options
context:
space:
mode:
authorBurdette Lamar <BurdetteLamar@Yahoo.com>2023-12-11 14:38:16 -0600
committerGitHub <noreply@github.com>2023-12-11 15:38:16 -0500
commite1d995a96cf99387ce1798904c3051ba11e43d18 (patch)
tree3ca806acb2180074085ceefb46f58642862da50b /complex.c
parent687d29f93ce45bd6721fc06530015a147e4057f0 (diff)
[DOC] Complex doc (#9185)
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/complex.c b/complex.c
index 88b4e02177..af4de45289 100644
--- a/complex.c
+++ b/complex.c
@@ -524,14 +524,15 @@ static VALUE nucomp_s_convert(int argc, VALUE *argv, VALUE klass);
/*
* call-seq:
- * Complex(abs, arg = 0, exception: true) -> complex or nil
+ * Complex(real, imag = 0, exception: true) -> complex or nil
* Complex(s, exception: true) -> complex or nil
*
* Returns a new \Complex object if the arguments are valid;
* otherwise raises an exception if +exception+ is +true+;
* otherwise returns +nil+.
*
- * With Numeric argument +abs+, returns <tt>Complex.rect(abs, arg)</tt> if the arguments are valid.
+ * With Numeric arguments +real+ and +imag+,
+ * returns <tt>Complex.rect(real, imag)</tt> if the arguments are valid.
*
* With string argument +s+, returns a new \Complex object if the argument is valid;
* the string may have:
@@ -751,12 +752,19 @@ nucomp_s_polar(int argc, VALUE *argv, VALUE klass)
/*
* call-seq:
- * cmp.real -> real
+ * real -> numeric
*
- * Returns the real part.
+ * Returns the real value for +self+:
+ *
+ * Complex(7).real #=> 7
+ * Complex(9, -4).real #=> 9
+ *
+ * If +self+ was created with
+ * {polar coordinates}[rdoc-ref:Complex@Polar+Coordinates], the returned value
+ * is computed, and may be inexact:
+ *
+ * Complex.polar(1, Math::PI/4).real # => 0.7071067811865476 # Square root of 2.
*
- * Complex(7).real #=> 7
- * Complex(9, -4).real #=> 9
*/
VALUE
rb_complex_real(VALUE self)
@@ -767,13 +775,21 @@ rb_complex_real(VALUE self)
/*
* call-seq:
- * cmp.imag -> real
- * cmp.imaginary -> real
+ * imag -> numeric
*
- * Returns the imaginary part.
+ * Returns the imaginary value for +self+:
*
* Complex(7).imaginary #=> 0
* Complex(9, -4).imaginary #=> -4
+ *
+ * If +self+ was created with
+ * {polar coordinates}[rdoc-ref:Complex@Polar+Coordinates], the returned value
+ * is computed, and may be inexact:
+ *
+ * Complex.polar(1, Math::PI/4).imag # => 0.7071067811865476 # Square root of 2.
+ *
+ * \Complex#imaginary is an alias for \Complex#imag.
+ *
*/
VALUE
rb_complex_imag(VALUE self)