Skip to content

Commit

Permalink
RDoc for complex.c
Browse files Browse the repository at this point in the history
  • Loading branch information
BurdetteLamar authored and peterzhu2118 committed Dec 24, 2023
1 parent f0efedd commit 86ef381
Showing 1 changed file with 36 additions and 43 deletions.
79 changes: 36 additions & 43 deletions complex.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 86ef381

Please sign in to comment.