aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKouhei Yanagita <yanagi@shakenbu.org>2022-07-21 18:57:13 +0900
committerYusuke Endoh <mame@ruby-lang.org>2022-08-12 15:57:52 +0900
commit24e33b84b5adb29d1d2f541acfba65e225b91b55 (patch)
tree93f798f0dfcdbb0cb763a240a53c92a8a5530acd
parent4165fd0e763439421296fbc95d754ad53e6ae84f (diff)
downloadruby-24e33b84b5adb29d1d2f541acfba65e225b91b55.tar.gz
Remove Numeric#ceildiv
-rw-r--r--complex.c1
-rw-r--r--numeric.c26
-rw-r--r--test/ruby/test_complex.rb1
-rw-r--r--test/ruby/test_numeric.rb14
4 files changed, 0 insertions, 42 deletions
diff --git a/complex.c b/complex.c
index 865466c499..d625ced7fa 100644
--- a/complex.c
+++ b/complex.c
@@ -2335,7 +2335,6 @@ Init_Complex(void)
rb_undef_method(rb_cComplex, "%");
rb_undef_method(rb_cComplex, "div");
rb_undef_method(rb_cComplex, "divmod");
- rb_undef_method(rb_cComplex, "ceildiv");
rb_undef_method(rb_cComplex, "floor");
rb_undef_method(rb_cComplex, "ceil");
rb_undef_method(rb_cComplex, "modulo");
diff --git a/numeric.c b/numeric.c
index df0c016b9e..9574bfe024 100644
--- a/numeric.c
+++ b/numeric.c
@@ -658,31 +658,6 @@ num_div(VALUE x, VALUE y)
/*
* call-seq:
- * ceildiv(other) -> integer
- *
- * Returns the quotient <tt>self/other</tt> as an integer, rounding up to the nearest integer.
- * This method uses method +/+ in the derived class of +self+.
- * (\Numeric itself does not define method +/+.)
- *
- * Of the Core and Standard Library classes,
- * Float and Rational use this implementation.
- *
- * 3.0.ceildiv(3.0) # => 1
- * 4.0.ceildiv(3.0) # => 2
- *
- * 4.0.ceildiv(-3.0) # => -1
- * -4.0.ceildiv(3.0) # => -1
- * -4.0.ceildiv(-3.0) # => 2
- */
-static VALUE
-num_ceildiv(VALUE x, VALUE y)
-{
- VALUE tmp = num_div(x, num_uminus(y));
- return num_uminus(tmp);
-}
-
-/*
- * call-seq:
* self % other -> real_numeric
*
* Returns +self+ modulo +other+ as a real number.
@@ -6247,7 +6222,6 @@ Init_Numeric(void)
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, "ceildiv", num_ceildiv, 1);
rb_define_method(rb_cNumeric, "div", num_div, 1);
rb_define_method(rb_cNumeric, "divmod", num_divmod, 1);
rb_define_method(rb_cNumeric, "%", num_modulo, 1);
diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb
index 5cf52e812e..a3a7546575 100644
--- a/test/ruby/test_complex.rb
+++ b/test/ruby/test_complex.rb
@@ -915,7 +915,6 @@ class Complex_Test < Test::Unit::TestCase
assert_not_respond_to(c, :%)
assert_not_respond_to(c, :div)
assert_not_respond_to(c, :divmod)
- assert_not_respond_to(c, :ceildiv)
assert_not_respond_to(c, :floor)
assert_not_respond_to(c, :ceil)
assert_not_respond_to(c, :modulo)
diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb
index 068f9a56eb..0593cb535d 100644
--- a/test/ruby/test_numeric.rb
+++ b/test/ruby/test_numeric.rb
@@ -482,18 +482,4 @@ class TestNumeric < Test::Unit::TestCase
assert_equal(0, -2.pow(3, 1))
end
- def test_ceildiv
- assert_equal(0, 0.0.ceildiv(3.0))
- assert_equal(1, 1.0.ceildiv(3.0))
- assert_equal(1, 3.0.ceildiv(3.0))
- assert_equal(2, 4.0.ceildiv(3.0))
-
- assert_equal(-1, 4.0.ceildiv(-3.0))
- assert_equal(-1, -4.0.ceildiv(3.0))
- assert_equal(2, -4.0.ceildiv(-3.0))
-
- assert_equal(3, 3.0.ceildiv(1.2))
- assert_equal(3, 3.0.ceildiv(6/5r))
- assert_equal(3, (7r/2).ceildiv(6/5r))
- end
end