summaryrefslogtreecommitdiffstats
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
commitc36bc82b1c329664a0472a574d530905b904565f (patch)
tree6a8d6ec1a1bd88e986408c1848666f67df129df2 /complex.c
parentd248ce8f53d6df3b5521018ac083ac31271236d3 (diff)
downloadruby-c36bc82b1c329664a0472a574d530905b904565f.tar.gz
ruby-c36bc82b1c329664a0472a574d530905b904565f.tar.xz
ruby-c36bc82b1c329664a0472a574d530905b904565f.zip
* complex.c; edited rdoc.
* rational.c; ditto. git-svn-id: http://svn.ruby-lang.org/repos/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 c15c9a863..3ebbbd3f6 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)
{