diff options
author | Nobuyoshi Nakada <[email protected]> | 2019-08-02 11:28:24 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2019-08-02 11:28:24 +0900 |
commit | 19006b711d8649b69d6f9dafad073a2f57201dd7 (patch) | |
tree | ccd3bc2e644f8920cb54bb617dc17f4eeb540d3a /rational.c | |
parent | f9a0492b76956b545c746ab0d3ec0e555e77dfcd (diff) |
Expanded f_quo
Diffstat (limited to 'rational.c')
-rw-r--r-- | rational.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/rational.c b/rational.c index 1dc08a082d..fdaf4d601b 100644 --- a/rational.c +++ b/rational.c @@ -1602,7 +1602,16 @@ f_ceil(VALUE x) } #define id_quo rb_intern("quo") -#define f_quo(x,y) rb_funcall((x), id_quo, 1, (y)) +static VALUE +f_quo(VALUE x, VALUE y) +{ + if (RB_INTEGER_TYPE_P(x)) + return rb_int_div(x, y); + if (RB_FLOAT_TYPE_P(x)) + return DBL2NUM(RFLOAT_VALUE(x) / RFLOAT_VALUE(y)); + + return rb_funcallv(x, id_quo, 1, &y); +} #define f_reciprocal(x) f_quo(ONE, (x)) |