ruby-changes:4406
From: ko1@a...
Date: Fri, 4 Apr 2008 01:01:38 +0900 (JST)
Subject: [ruby-changes:4406] matz - Ruby:r15897 (trunk): * bignum.c (Init_Bignum): rdiv method removed.
matz 2008-04-04 01:01:16 +0900 (Fri, 04 Apr 2008)
New Revision: 15897
Modified files:
trunk/ChangeLog
trunk/bignum.c
trunk/complex.c
trunk/numeric.c
trunk/rational.c
trunk/test/ruby/test_complex.rb
trunk/test/ruby/test_rational.rb
Log:
* bignum.c (Init_Bignum): rdiv method removed. [ruby-dev:34242]
* complex.c (nucomp_quo): ditto.
* numeric.c (num_rdiv): ditto.
* rational.c (nurat_div): ditto.
* complex.c (nucomp_fdiv): fdiv implementation restored.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/numeric.c?r1=15897&r2=15896&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_complex.rb?r1=15897&r2=15896&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/complex.c?r1=15897&r2=15896&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15897&r2=15896&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_rational.rb?r1=15897&r2=15896&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/bignum.c?r1=15897&r2=15896&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/rational.c?r1=15897&r2=15896&diff_format=u
Index: complex.c
===================================================================
--- complex.c (revision 15896)
+++ complex.c (revision 15897)
@@ -791,7 +791,7 @@
}
static VALUE
-nucomp_rdiv(VALUE self, VALUE other)
+nucomp_quo(VALUE self, VALUE other)
{
get_dat1(self);
@@ -800,7 +800,6 @@
f_to_r(dat->image)), other);
}
-#if 0
static VALUE
nucomp_fdiv(VALUE self, VALUE other)
{
@@ -810,7 +809,6 @@
f_to_f(dat->real),
f_to_f(dat->image)), other);
}
-#endif
static VALUE
nucomp_expt(VALUE self, VALUE other)
@@ -1550,9 +1548,8 @@
rb_define_method(rb_cComplex, "-", nucomp_sub, 1);
rb_define_method(rb_cComplex, "*", nucomp_mul, 1);
rb_define_method(rb_cComplex, "/", nucomp_div, 1);
- rb_define_method(rb_cComplex, "quo", nucomp_rdiv, 1);
- rb_define_method(rb_cComplex, "rdiv", nucomp_rdiv, 1);
- rb_define_method(rb_cComplex, "fdiv", nucomp_rdiv, 1);
+ rb_define_method(rb_cComplex, "quo", nucomp_quo, 1);
+ rb_define_method(rb_cComplex, "fdiv", nucomp_fdiv, 1);
rb_define_method(rb_cComplex, "**", nucomp_expt, 1);
rb_define_method(rb_cComplex, "==", nucomp_equal_p, 1);
Index: ChangeLog
===================================================================
--- ChangeLog (revision 15896)
+++ ChangeLog (revision 15897)
@@ -1,3 +1,15 @@
+Fri Apr 4 00:42:26 2008 Yukihiro Matsumoto <matz@r...>
+
+ * bignum.c (Init_Bignum): rdiv method removed. [ruby-dev:34242]
+
+ * complex.c (nucomp_quo): ditto.
+
+ * numeric.c (num_rdiv): ditto.
+
+ * rational.c (nurat_div): ditto.
+
+ * complex.c (nucomp_fdiv): fdiv implementation restored.
+
Thu Apr 3 21:51:45 2008 Tadayoshi Funaba <tadf@d...>
* complex.c (nucomp_int_check): function for DRY real check.
Index: numeric.c
===================================================================
--- numeric.c (revision 15896)
+++ numeric.c (revision 15897)
@@ -266,27 +266,14 @@
* num.quo(numeric) => result
*
* Suppose to return most accurate division result, which
- * by default in ratinal number for 1.9.
+ * is either rational or float (if any of operands are float).
*
*/
-/*
- * Document-method: rdiv
- *
- * call-seq:
- * num.rdiv(numeric) => result
- *
- * Performs rational number division.
- *
- * 654321.rdiv(13731) #=> Rational(218107, 4577)
- * 654321.rdiv(13731.5) #=> Rational(1308642, 27463)
- *
- */
-
static VALUE
-num_rdiv(VALUE x, VALUE y)
+num_quo(VALUE x, VALUE y)
{
- return rb_funcall(rb_Rational1(x), rb_intern("rdiv"), 1, y);
+ return rb_funcall(rb_Rational1(x), rb_intern("quo"), 1, y);
}
static VALUE num_floor(VALUE num);
@@ -2248,8 +2235,8 @@
* Returns the floating point result of dividing <i>fix</i> by
* <i>numeric</i>.
*
- * 654321.rdiv(13731) #=> Rational(218107, 4577)
- * 654321.rdiv(13731.24) #=> Rational(1308642, 27463)
+ * 654321.quo(13731) #=> Rational(218107, 4577)
+ * 654321.quo(13731.24) #=> xxx
*
*/
@@ -3178,8 +3165,7 @@
rb_define_method(rb_cNumeric, "<=>", num_cmp, 1);
rb_define_method(rb_cNumeric, "eql?", num_eql, 1);
rb_define_method(rb_cNumeric, "fdiv", num_fdiv, 1);
- rb_define_method(rb_cNumeric, "quo", num_rdiv, 1);
- rb_define_method(rb_cNumeric, "rdiv", num_rdiv, 1);
+ rb_define_method(rb_cNumeric, "quo", num_quo, 1);
rb_define_method(rb_cNumeric, "div", num_div, 1);
rb_define_method(rb_cNumeric, "divmod", num_divmod, 1);
rb_define_method(rb_cNumeric, "modulo", num_modulo, 1);
Index: bignum.c
===================================================================
--- bignum.c (revision 15896)
+++ bignum.c (revision 15897)
@@ -2650,7 +2650,6 @@
rb_define_method(rb_cBignum, "modulo", rb_big_modulo, 1);
rb_define_method(rb_cBignum, "remainder", rb_big_remainder, 1);
rb_define_method(rb_cBignum, "quo", rb_big_quo, 1);
- rb_define_method(rb_cBignum, "rdiv", rb_big_quo, 1);
rb_define_method(rb_cBignum, "fdiv", rb_big_fdiv, 1);
rb_define_method(rb_cBignum, "**", rb_big_pow, 1);
rb_define_method(rb_cBignum, "&", rb_big_and, 1);
Index: test/ruby/test_complex.rb
===================================================================
--- test/ruby/test_complex.rb (revision 15896)
+++ test/ruby/test_complex.rb (revision 15897)
@@ -413,30 +413,6 @@
end
end
- def test_rdiv
- if defined?(Rational) && !Rational.instance_variable_get('@RCS_ID')
- c = Complex(1,2)
- c2 = Complex(2,3)
-
- assert_equal(Complex(Rational(8,13),Rational(1,13)), c.rdiv(c2))
-
- c = Complex(1.0,2.0)
- c2 = Complex(2.0,3.0)
-
- r = c.rdiv(c2)
- assert_in_delta(0.615, r.real, 0.001)
- assert_in_delta(0.076, r.image, 0.001)
-
- c = Complex(1,2)
- c2 = Complex(2,3)
-
- assert_equal(Complex(Rational(1,2),1), c.rdiv(2))
-
- assert_equal(Complex(Rational(1,2),Rational(1)), c / Rational(2))
- assert_equal(Complex(Rational(3,2),Rational(3)), c / Rational(2,3))
- end
- end
-
def test_fdiv
c = Complex(1,2)
c2 = Complex(2,3)
@@ -880,10 +856,10 @@
end
if defined?(Rational) && !Rational.instance_variable_get('@RCS_ID')
- assert_equal(Rational(1,2), 1.rdiv(2))
- assert_equal(Rational(5000000000), 10000000000.rdiv(2))
- assert_equal(Rational(1,2), 1.0.rdiv(2))
- assert_equal(Rational(1,4), Rational(1,2).rdiv(2))
+ assert_equal(Rational(1,2), 1.quo(2))
+ assert_equal(Rational(5000000000), 10000000000.quo(2))
+ assert_equal(Rational(1,2), 1.0.quo(2))
+ assert_equal(Rational(1,4), Rational(1,2).quo(2))
assert_equal(Complex(Rational(1,2),Rational(1)), Complex(1,2).quo(2))
end
Index: test/ruby/test_rational.rb
===================================================================
--- test/ruby/test_rational.rb (revision 15896)
+++ test/ruby/test_rational.rb (revision 15897)
@@ -502,16 +502,6 @@
assert_equal(Rational(0.25), c.quo(2.0))
end
- def test_rdiv
- c = Rational(1,2)
- c2 = Rational(2,3)
-
- assert_equal(Rational(3,4), c.rdiv(c2))
-
- assert_equal(Rational(1,4), c.rdiv(2))
- assert_equal(Rational(0.25), c.rdiv(2.0))
- end
-
def test_fdiv
c = Rational(1,2)
c2 = Rational(2,3)
@@ -946,11 +936,6 @@
assert_equal(Rational(1,2), 1.0.quo(2))
assert_equal(Rational(1,4), Rational(1,2).quo(2))
- assert_equal(Rational(1,2), 1.rdiv(2))
- assert_equal(Rational(5000000000), 10000000000.rdiv(2))
- assert_equal(Rational(1,2), 1.0.rdiv(2))
- assert_equal(Rational(1,4), Rational(1,2).rdiv(2))
-
assert_equal(0.5, 1.fdiv(2))
assert_equal(5000000000.0, 10000000000.fdiv(2))
assert_equal(0.5, 1.0.fdiv(2))
Index: rational.c
===================================================================
--- rational.c (revision 15896)
+++ rational.c (revision 15897)
@@ -781,7 +781,7 @@
#define f_to_r(x) rb_funcall(x, id_to_r, 0)
static VALUE
-nurat_division(VALUE self, VALUE other, int rdiv)
+nurat_div(VALUE self, VALUE other)
{
again:
switch (TYPE(other)) {
@@ -797,10 +797,6 @@
other, ONE, '/');
}
case T_FLOAT:
- if (rdiv) {
- other = f_to_r(other);
- goto again;
- }
return rb_funcall(f_to_f(self), '/', 1, other);
case T_RATIONAL:
if (f_zero_p(other))
@@ -818,18 +814,6 @@
}
static VALUE
-nurat_div(VALUE self, VALUE other)
-{
- return nurat_division(self, other, Qfalse);
-}
-
-static VALUE
-nurat_rdiv(VALUE self, VALUE other)
-{
- return nurat_division(self, other, Qtrue);
-}
-
-static VALUE
nurat_fdiv(VALUE self, VALUE other)
{
return f_div(f_to_f(self), other);
@@ -1549,8 +1533,7 @@
rb_define_method(rb_cRational, "-", nurat_sub, 1);
rb_define_method(rb_cRational, "*", nurat_mul, 1);
rb_define_method(rb_cRational, "/", nurat_div, 1);
- rb_define_method(rb_cRational, "quo", nurat_rdiv, 1);
- rb_define_method(rb_cRational, "rdiv", nurat_rdiv, 1);
+ rb_define_method(rb_cRational, "quo", nurat_div, 1);
rb_define_method(rb_cRational, "fdiv", nurat_fdiv, 1);
rb_define_method(rb_cRational, "**", nurat_expt, 1);
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/