summaryrefslogtreecommitdiff
path: root/complex.c
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-19 20:10:13 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-19 20:10:13 +0000
commit63f2557b56ca791e9fee0fdeba4ad5f6aa378fe2 (patch)
tree6a8d6ec1a1bd88e986408c1848666f67df129df2 /complex.c
parentc21b9570dc93293a80f1ff99db36c518ffdd9cb7 (diff)
* complex.c; edited rdoc.
* rational.c; ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/complex.c b/complex.c
index c15c9a863c..3ebbbd3f6e 100644
--- a/complex.c
+++ b/complex.c
@@ -814,10 +814,6 @@ nucomp_equal_p(VALUE self, VALUE other)
return f_equal_p(other, self);
}
-/*
- * call-seq:
- * cmp.coerce(numeric) => array
- */
static VALUE
nucomp_coerce(VALUE self, VALUE other)
{
@@ -1315,6 +1311,24 @@ make_patterns(void)
#define id_gsub_bang rb_intern("gsub!")
#define f_gsub_bang(x,y,z) rb_funcall(x, id_gsub_bang, 2, y, z)
+/*
+ * call-seq:
+ * string.to_c => complex
+ *
+ * Returns a complex which denotes string form.
+ *
+ * For example:
+ *
+ * '9'.to_c #=> (9+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)
+ */
static VALUE
string_to_c_internal(VALUE self)
{