diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-08-08 02:13:11 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-08-08 02:13:11 +0900 |
| commit | 66e2928bd481a0dd2762da9428af39b3384c0852 (patch) | |
| tree | 1b658789e884d76f4d23b8afec34e142522ad241 /src/vm.c | |
| parent | 8494557006c00a02643bf4d92007a5480932bc6d (diff) | |
| download | mruby-66e2928bd481a0dd2762da9428af39b3384c0852.tar.gz mruby-66e2928bd481a0dd2762da9428af39b3384c0852.zip | |
Float values divided by zero should honor signs; fix #3766
It also fixes unexpected resurrection of #3745 by #3752
Diffstat (limited to 'src/vm.c')
| -rw-r--r-- | src/vm.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -2389,8 +2389,10 @@ RETRY_TRY_BLOCK: mrb_int x = mrb_fixnum(regs[a]); mrb_int y = mrb_fixnum(regs[a+1]); double f; - if (y == 0 && x != 0) { - f = INFINITY; + if (y == 0) { + if (x == 0) f = NAN; + else if (x > 0) f = INFINITY; + else if (x < 0) f = -INFINITY; } else { f = (mrb_float)x / (mrb_float)y; |
