зеркало из https://github.com/github/ruby.git
{Fixnum,Bignum}#divmod is unified into Integer.
* numeric.c (int_divmod): {Fixnum,Bignum}#divmod is unified into Integer. * bignum.c (rb_big_divmod): Don't define Bignum#divmod. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
bda463c134
Коммит
1b1a1ed6c8
|
@ -1,3 +1,10 @@
|
||||||
|
Sat Apr 30 14:04:30 2016 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* numeric.c (int_divmod): {Fixnum,Bignum}#divmod is unified into
|
||||||
|
Integer.
|
||||||
|
|
||||||
|
* bignum.c (rb_big_divmod): Don't define Bignum#divmod.
|
||||||
|
|
||||||
Sat Apr 30 13:20:00 2016 Tanaka Akira <akr@fsij.org>
|
Sat Apr 30 13:20:00 2016 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* numeric.c (int_fdiv): {Fixnum,Bignum}#fdiv is unified into
|
* numeric.c (int_fdiv): {Fixnum,Bignum}#fdiv is unified into
|
||||||
|
|
8
bignum.c
8
bignum.c
|
@ -6176,13 +6176,6 @@ rb_big_remainder(VALUE x, VALUE y)
|
||||||
return bignorm(z);
|
return bignorm(z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* call-seq:
|
|
||||||
* big.divmod(numeric) -> array
|
|
||||||
*
|
|
||||||
* See <code>Numeric#divmod</code>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_big_divmod(VALUE x, VALUE y)
|
rb_big_divmod(VALUE x, VALUE y)
|
||||||
{
|
{
|
||||||
|
@ -6920,7 +6913,6 @@ Init_Bignum(void)
|
||||||
rb_define_method(rb_cBignum, "/", rb_big_div, 1);
|
rb_define_method(rb_cBignum, "/", rb_big_div, 1);
|
||||||
rb_define_method(rb_cBignum, "%", rb_big_modulo, 1);
|
rb_define_method(rb_cBignum, "%", rb_big_modulo, 1);
|
||||||
rb_define_method(rb_cBignum, "div", rb_big_idiv, 1);
|
rb_define_method(rb_cBignum, "div", rb_big_idiv, 1);
|
||||||
rb_define_method(rb_cBignum, "divmod", rb_big_divmod, 1);
|
|
||||||
rb_define_method(rb_cBignum, "modulo", rb_big_modulo, 1);
|
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, "remainder", rb_big_remainder, 1);
|
||||||
|
|
||||||
|
|
20
numeric.c
20
numeric.c
|
@ -3536,11 +3536,11 @@ rb_int_modulo(VALUE x, VALUE y)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: Fixnum#divmod
|
* Document-method: Integer#divmod
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* fix.divmod(numeric) -> array
|
* integer.divmod(numeric) -> array
|
||||||
*
|
*
|
||||||
* See Numeric#divmod.
|
* See <code>Numeric#divmod</code>.
|
||||||
*/
|
*/
|
||||||
static VALUE
|
static VALUE
|
||||||
fix_divmod(VALUE x, VALUE y)
|
fix_divmod(VALUE x, VALUE y)
|
||||||
|
@ -3571,6 +3571,18 @@ fix_divmod(VALUE x, VALUE y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
int_divmod(VALUE x, VALUE y)
|
||||||
|
{
|
||||||
|
if (FIXNUM_P(x)) {
|
||||||
|
return fix_divmod(x, y);
|
||||||
|
}
|
||||||
|
else if (RB_TYPE_P(x, T_BIGNUM)) {
|
||||||
|
return rb_big_divmod(x, y);
|
||||||
|
}
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: Integer#**
|
* Document-method: Integer#**
|
||||||
* call-seq:
|
* call-seq:
|
||||||
|
@ -4830,7 +4842,7 @@ Init_Numeric(void)
|
||||||
rb_define_method(rb_cFixnum, "div", fix_idiv, 1);
|
rb_define_method(rb_cFixnum, "div", fix_idiv, 1);
|
||||||
rb_define_method(rb_cFixnum, "%", fix_mod, 1);
|
rb_define_method(rb_cFixnum, "%", fix_mod, 1);
|
||||||
rb_define_method(rb_cFixnum, "modulo", fix_mod, 1);
|
rb_define_method(rb_cFixnum, "modulo", fix_mod, 1);
|
||||||
rb_define_method(rb_cFixnum, "divmod", fix_divmod, 1);
|
rb_define_method(rb_cInteger, "divmod", int_divmod, 1);
|
||||||
rb_define_method(rb_cInteger, "fdiv", int_fdiv, 1);
|
rb_define_method(rb_cInteger, "fdiv", int_fdiv, 1);
|
||||||
rb_define_method(rb_cInteger, "**", rb_int_pow, 1);
|
rb_define_method(rb_cInteger, "**", rb_int_pow, 1);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче