Float values divided by zero should honor signs; fix
It also fixes unexpected resurrection of by
MODIFY
src/numeric.c
src/numeric.c
@@ -187,12 +187,9 @@ flodivmod(mrb_state *mrb, mrb_float x, mrb_float y, mrb_float *divp, mrb_float *
mrb_float mod;
if (y == 0.0) {
- if (x == 0.0) {
- div = NAN;
- }
- else {
- div = INFINITY;
- }
+ if (x == 0.0) div = NAN;
+ else if (x > 0.0) div = INFINITY;
+ else if (x < 0.0) div = -INFINITY;
mod = NAN;
}
else {

MODIFY
src/vm.c
src/vm.c
@@ -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;

Float values divided by zero should honor signs; fix #3766

It also fixes unexpected resurrection of #3745 by #3752