diff options
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 32 |
1 files changed, 23 insertions, 9 deletions
@@ -1800,15 +1800,9 @@ bigdivmod(VALUE x, VALUE y, VALUE *divp, VALUE *modp) } } -/* - * call-seq: - * big / other => Numeric - * - * Divides big by other, returning the result. - */ -VALUE -rb_big_div(VALUE x, VALUE y) +static VALUE +rb_big_divide(VALUE x, VALUE y, ID op) { VALUE z; @@ -1824,7 +1818,7 @@ rb_big_div(VALUE x, VALUE y) return DOUBLE2NUM(rb_big2dbl(x) / RFLOAT_VALUE(y)); default: - return rb_num_coerce_bin(x, y, '/'); + return rb_num_coerce_bin(x, y, op); } bigdivmod(x, y, &z, 0); @@ -1833,6 +1827,25 @@ rb_big_div(VALUE x, VALUE y) /* * call-seq: + * big / other => Numeric + * + * Divides big by other, returning the result. + */ + +VALUE +rb_big_div(VALUE x, VALUE y) +{ + return rb_big_divide(x, y, '/'); +} + +VALUE +rb_big_idiv(VALUE x, VALUE y) +{ + return rb_big_divide(x, y, rb_intern("div")); +} + +/* + * call-seq: * big % other => Numeric * big.modulo(other) => Numeric * @@ -2663,6 +2676,7 @@ Init_Bignum(void) rb_define_method(rb_cBignum, "*", rb_big_mul, 1); rb_define_method(rb_cBignum, "/", rb_big_div, 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, "divmod", rb_big_divmod, 1); rb_define_method(rb_cBignum, "modulo", rb_big_modulo, 1); rb_define_method(rb_cBignum, "remainder", rb_big_remainder, 1); |