summaryrefslogtreecommitdiff
path: root/complex.c
diff options
context:
space:
mode:
authorBurdetteLamar <burdettelamar@yahoo.com>2023-12-24 13:26:07 -0600
committerPeter Zhu <peter@peterzhu.ca>2023-12-24 14:56:06 -0500
commit86ef38194bf2f5c854cab0adf29984594ee4a6ec (patch)
treee756f24d7a8e59b827e8bf360bf170c529f78a77 /complex.c
parentf0efeddd41f96d3afae9af73a3dc594d86614f4b (diff)
RDoc for complex.c
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c79
1 files changed, 36 insertions, 43 deletions
diff --git a/complex.c b/complex.c
index 9057771b5c..d29189e367 100644
--- a/complex.c
+++ b/complex.c
@@ -1932,9 +1932,9 @@ nilclass_to_c(VALUE self)
/*
* call-seq:
- * num.to_c -> complex
+ * to_c -> complex
*
- * Returns the value as a complex.
+ * Returns +self+ as a Complex object.
*/
static VALUE
numeric_to_c(VALUE self)
@@ -2232,32 +2232,30 @@ string_to_c_strict(VALUE self, int raise)
/*
* call-seq:
- * str.to_c -> complex
- *
- * Returns a complex which denotes the string form. The parser
- * ignores leading whitespaces and trailing garbage. Any digit
- * sequences can be separated by an underscore. Returns zero for null
- * or garbage string.
- *
- * '9'.to_c #=> (9+0i)
- * '2.5'.to_c #=> (2.5+0i)
- * '2.5/1'.to_c #=> ((5/2)+0i)
- * '-3/2'.to_c #=> ((-3/2)+0i)
- * '-i'.to_c #=> (0-1i)
- * '45i'.to_c #=> (0+45i)
- * '3-4i'.to_c #=> (3-4i)
- * '-4e2-4e-2i'.to_c #=> (-400.0-0.04i)
- * '-0.0-0.0i'.to_c #=> (-0.0-0.0i)
- * '1/2+3/4i'.to_c #=> ((1/2)+(3/4)*i)
- * 'ruby'.to_c #=> (0+0i)
- *
- * Polar form:
- * include Math
- * "1.0@0".to_c #=> (1+0.0i)
- * "1.0@#{PI/2}".to_c #=> (0.0+1i)
- * "1.0@#{PI}".to_c #=> (-1+0.0i)
- *
- * See Kernel.Complex.
+ * to_c -> complex
+ *
+ * Returns +self+ interpreted as a Complex object;
+ * leading whitespace and trailing garbage are ignored:
+ *
+ * '9'.to_c # => (9+0i)
+ * '2.5'.to_c # => (2.5+0i)
+ * '2.5/1'.to_c # => ((5/2)+0i)
+ * '-3/2'.to_c # => ((-3/2)+0i)
+ * '-i'.to_c # => (0-1i)
+ * '45i'.to_c # => (0+45i)
+ * '3-4i'.to_c # => (3-4i)
+ * '-4e2-4e-2i'.to_c # => (-400.0-0.04i)
+ * '-0.0-0.0i'.to_c # => (-0.0-0.0i)
+ * '1/2+3/4i'.to_c # => ((1/2)+(3/4)*i)
+ * '1.0@0'.to_c # => (1+0.0i)
+ * "1.0@#{Math::PI/2}".to_c # => (0.0+1i)
+ * "1.0@#{Math::PI}".to_c # => (-1+0.0i)
+ *
+ * Returns \Complex zero if the string cannot be converted:
+ *
+ * 'ruby'.to_c # => (0+0i)
+ *
+ * See Kernel#Complex.
*/
static VALUE
string_to_c(VALUE self)
@@ -2368,9 +2366,9 @@ nucomp_s_convert(int argc, VALUE *argv, VALUE klass)
/*
* call-seq:
- * num.abs2 -> real
+ * abs2 -> real
*
- * Returns square of self.
+ * Returns the square of +self+.
*/
static VALUE
numeric_abs2(VALUE self)
@@ -2380,11 +2378,9 @@ numeric_abs2(VALUE self)
/*
* call-seq:
- * num.arg -> 0 or float
- * num.angle -> 0 or float
- * num.phase -> 0 or float
+ * arg -> 0 or Math::PI
*
- * Returns 0 if the value is positive, pi otherwise.
+ * Returns zero if +self+ is positive, Math::PI otherwise.
*/
static VALUE
numeric_arg(VALUE self)
@@ -2396,10 +2392,9 @@ numeric_arg(VALUE self)
/*
* call-seq:
- * num.rect -> array
- * num.rectangular -> array
+ * rect -> array
*
- * Returns an array; [num, 0].
+ * Returns array <tt>[self, 0]</tt>.
*/
static VALUE
numeric_rect(VALUE self)
@@ -2409,9 +2404,9 @@ numeric_rect(VALUE self)
/*
* call-seq:
- * num.polar -> array
+ * polar -> array
*
- * Returns an array; [num.abs, num.arg].
+ * Returns array <tt>[self.abs, self.arg]</tt>.
*/
static VALUE
numeric_polar(VALUE self)
@@ -2439,11 +2434,9 @@ numeric_polar(VALUE self)
/*
* call-seq:
- * flo.arg -> 0 or float
- * flo.angle -> 0 or float
- * flo.phase -> 0 or float
+ * arg -> 0 or Math::PI
*
- * Returns 0 if the value is positive, pi otherwise.
+ * Returns 0 if +self+ is positive, Math::PI otherwise.
*/
static VALUE
float_arg(VALUE self)