diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-06-15 08:36:07 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-06-15 08:36:07 +0900 |
| commit | 040b57fae5ab001fdb04271131dbe33a713170d8 (patch) | |
| tree | b92e20bbf4d42849e207bdf3efdbbda1f23b23d5 | |
| parent | c7b1622f40bd7625eaebde228a2c4255488c4ee9 (diff) | |
| download | mruby-040b57fae5ab001fdb04271131dbe33a713170d8.tar.gz mruby-040b57fae5ab001fdb04271131dbe33a713170d8.zip | |
1 % 0 should return NaN; close #283
| -rw-r--r-- | src/numeric.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/numeric.c b/src/numeric.c index 746078fd9..de43dccba 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -767,12 +767,11 @@ static mrb_value fix_mod(mrb_state *mrb, mrb_value x) { mrb_value y; - mrb_int a; + mrb_int a, b; mrb_get_args(mrb, "o", &y); - a = mrb_fixnum(x); - if (FIXNUM_P(y)) { + if (FIXNUM_P(y) && (b=mrb_fixnum(y)) != 0) { mrb_int mod; fixdivmod(mrb, a, mrb_fixnum(y), 0, &mod); |
