ruby-changes:56906
From: Nobuyoshi <ko1@a...>
Date: Sat, 10 Aug 2019 14:41:36 +0900 (JST)
Subject: [ruby-changes:56906] Nobuyoshi Nakada: d69ffa4d93 (master): Expanded f_quo
https://git.ruby-lang.org/ruby.git/commit/?id=d69ffa4d93 From d69ffa4d93b12ddfb0d77f146921eb5d2fd62919 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sat, 10 Aug 2019 14:30:34 +0900 Subject: Expanded f_quo diff --git a/complex.c b/complex.c index ed35b2b..ec60c00 100644 --- a/complex.c +++ b/complex.c @@ -285,7 +285,19 @@ f_eqeq_p(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/complex.c#L285 fun2(expt) fun2(fdiv) -fun2(quo) + +static VALUE +f_quo(VALUE x, VALUE y) +{ + if (RB_INTEGER_TYPE_P(x)) + return rb_numeric_quo(x, y); + if (RB_FLOAT_TYPE_P(x)) + return rb_float_div(x, y); + if (RB_TYPE_P(x, T_RATIONAL)) + return rb_numeric_quo(x, y); + + return rb_funcallv(x, id_quo, 1, &y); +} inline static int f_negative_p(VALUE x) diff --git a/internal.h b/internal.h index 76c10c8..2ba4986 100644 --- a/internal.h +++ b/internal.h @@ -1763,6 +1763,7 @@ VALUE rb_float_plus(VALUE x, VALUE y); https://github.com/ruby/ruby/blob/trunk/internal.h#L1763 VALUE rb_int_minus(VALUE x, VALUE y); VALUE rb_int_mul(VALUE x, VALUE y); VALUE rb_float_mul(VALUE x, VALUE y); +VALUE rb_float_div(VALUE x, VALUE y); VALUE rb_int_idiv(VALUE x, VALUE y); VALUE rb_int_modulo(VALUE x, VALUE y); VALUE rb_int_round(VALUE num, int ndigits, enum ruby_num_rounding_mode mode); diff --git a/numeric.c b/numeric.c index d56b2d6..724a7f3 100644 --- a/numeric.c +++ b/numeric.c @@ -1122,8 +1122,8 @@ rb_flo_div_flo(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1122 * Returns a new Float which is the result of dividing +float+ by +other+. */ -static VALUE -flo_div(VALUE x, VALUE y) +VALUE +rb_float_div(VALUE x, VALUE y) { double num = RFLOAT_VALUE(x); double den; @@ -5791,7 +5791,7 @@ Init_Numeric(void) https://github.com/ruby/ruby/blob/trunk/numeric.c#L5791 rb_define_method(rb_cFloat, "+", rb_float_plus, 1); rb_define_method(rb_cFloat, "-", flo_minus, 1); rb_define_method(rb_cFloat, "*", rb_float_mul, 1); - rb_define_method(rb_cFloat, "/", flo_div, 1); + rb_define_method(rb_cFloat, "/", rb_float_div, 1); rb_define_method(rb_cFloat, "quo", flo_quo, 1); rb_define_method(rb_cFloat, "fdiv", flo_quo, 1); rb_define_method(rb_cFloat, "%", flo_mod, 1); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/