diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-01-17 22:58:06 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-01-17 23:02:36 +0900 |
| commit | 12ff88563d09f7c5b9f1c03b7f10bdbebd25e647 (patch) | |
| tree | 7d565bb24b29aa51dd1ffa7f4f5efc5afde0f099 | |
| parent | c7452ff61f7bf8cb2c2ebd8ca6b2dfd844f70a1a (diff) | |
| download | mruby-12ff88563d09f7c5b9f1c03b7f10bdbebd25e647.tar.gz mruby-12ff88563d09f7c5b9f1c03b7f10bdbebd25e647.zip | |
Fix `int_quo` to do float division; fix #5268
| -rw-r--r-- | src/numeric.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/numeric.c b/src/numeric.c index 146eb635b..59136bece 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -177,9 +177,15 @@ int_quo(mrb_state *mrb, mrb_value xv) if (y == 0) { int_zerodiv(mrb); } - return mrb_fixnum_value(mrb_fixnum(xv) / y); + return mrb_fixnum_value(mrb_integer(xv) / y); #else - return int_div(mrb, xv); + mrb_float y; + + mrb_get_args(mrb, "f", &y); + if (y == 0) { + int_zerodiv(mrb); + } + return mrb_float_value(mrb, mrb_integer(xv) / y); #endif } |
