diff options
Diffstat (limited to 'src/numeric.c')
| -rw-r--r-- | src/numeric.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/numeric.c b/src/numeric.c index e80d5c136..c536f0614 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -237,17 +237,15 @@ flo_idiv(mrb_state *mrb, mrb_value xv) mrb_float mrb_num_div_flo(mrb_state *mrb, mrb_float x, mrb_float y) { - mrb_float f; - - if (y == 0) { - if (x > 0) f = INFINITY; - else if (x < 0) f = -INFINITY; - else /* if (x == 0) */ f = NAN; + if (y != 0.0) { + return x / y; + } + else if (x == 0.0) { + return NAN; } else { - f = x / y; + return x * (signbit(y) ? -1.0 : 1.0) * INFINITY; } - return f; } static mrb_value |
