summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-21 12:54:06 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-21 12:54:06 +0000
commit4d03af3d9cdedacadc1e967490c9201fec13fc53 (patch)
tree81f252fc070ca764b35b08daf5cb8d1b30cae46a
parentc07d295204de26a8926b5c58c2b849022e5db02b (diff)
* complex.c (nucomp_to_c): added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--complex.c16
2 files changed, 20 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index ce4e4dc8b3..95d05890bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Nov 21 21:53:29 2012 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * complex.c (nucomp_to_c): added.
+
Wed Nov 21 21:35:38 2012 Tadayoshi Funaba <tadf@dotrb.org>
* include/ruby/util.h: removed extra semicolon in definition of
diff --git a/complex.c b/complex.c
index d262e9a325..1d61fda950 100644
--- a/complex.c
+++ b/complex.c
@@ -1474,6 +1474,21 @@ nucomp_rationalize(int argc, VALUE *argv, VALUE self)
/*
* call-seq:
+ * complex.to_c -> self
+ *
+ * Returns self.
+ *
+ * Complex(2).to_c #=> (2+0i)
+ * Complex(-8, 6).to_c #=> (-8+6i)
+ */
+static VALUE
+nucomp_to_c(VALUE self)
+{
+ return self;
+}
+
+/*
+ * call-seq:
* nil.to_c -> (0+0i)
*
* Returns zero as a complex.
@@ -2178,6 +2193,7 @@ Init_Complex(void)
rb_define_method(rb_cComplex, "to_f", nucomp_to_f, 0);
rb_define_method(rb_cComplex, "to_r", nucomp_to_r, 0);
rb_define_method(rb_cComplex, "rationalize", nucomp_rationalize, -1);
+ rb_define_method(rb_cComplex, "to_c", nucomp_to_c, 0);
rb_define_method(rb_cNilClass, "to_c", nilclass_to_c, 0);
rb_define_method(rb_cNumeric, "to_c", numeric_to_c, 0);