summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-01-17 22:58:06 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-01-17 23:02:36 +0900
commit12ff88563d09f7c5b9f1c03b7f10bdbebd25e647 (patch)
tree7d565bb24b29aa51dd1ffa7f4f5efc5afde0f099 /src
parentc7452ff61f7bf8cb2c2ebd8ca6b2dfd844f70a1a (diff)
downloadmruby-12ff88563d09f7c5b9f1c03b7f10bdbebd25e647.tar.gz
mruby-12ff88563d09f7c5b9f1c03b7f10bdbebd25e647.zip
Fix `int_quo` to do float division; fix #5268
Diffstat (limited to 'src')
-rw-r--r--src/numeric.c10
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
}