`Float::NAN/0` should be `Float::NAN`; ref
#### Before this patch:
```console
$ bin/mruby -e 'p(Float::NAN/0)'
Infinity
```
#### After this patch (same as Ruby):
```console
$ bin/mruby -e 'p(Float::NAN/0)'
NaN
```
MODIFY
src/numeric.c
src/numeric.c
#define floor(f) floorf(f)
#define ceil(f) ceilf(f)
#define fmod(x,y) fmodf(x,y)
-#define copysign(x,y) copysignf(x,y)
#define FLO_TO_STR_PREC 8
#else
#define FLO_TO_STR_PREC 16
@@ -245,9 +244,7 @@ mrb_num_div_flo(mrb_state *mrb, mrb_float x, mrb_float y)
return NAN;
}
else {
- mrb_float a = copysign(1.0, x);
- mrb_float b = copysign(1.0, y);
- return a * b * INFINITY;
+ return x * (signbit(y) ? -1.0 : 1.0) * INFINITY;
}
}

MODIFY
test/t/float.rb
test/t/float.rb
@@ -35,16 +35,66 @@ assert('Float#*', '15.2.9.3.3') do
end
assert('Float#/', '15.2.9.3.4') do
- a = 3.123456789 / 3.123456789
- b = 3.123456789 / 1
-
- assert_float(1.0 , a)
- assert_float(3.123456789, b)
+ assert_float(1.0, 3.123456789 / 3.123456789)
+ assert_float(3.123456789, 3.123456789 / 1)
+ assert_float(2.875, -5.75 / -2.0)
+ assert_float(-2.875, 5.75 / -2)
+ assert_float(-2.875, -5.75 / 2.0)
+ assert_float(Float::NAN, 0.0 / 0.0)
+ assert_float(Float::NAN, -0.0 / -0.0)
+ assert_float(Float::NAN, -0.0 / 0.0)
+ assert_float(Float::NAN, Float::NAN / Float::NAN)
+ assert_float(Float::NAN, Float::NAN / 0.0)
+ assert_float(Float::NAN, Float::NAN / -0.0)
+ assert_float(Float::NAN, Float::NAN / 2.0)
+ assert_float(Float::NAN, Float::NAN / -2.0)
+ assert_float(Float::NAN, 0.0 / Float::NAN)
+ assert_float(Float::NAN, -0.0 / Float::NAN)
+ assert_float(Float::NAN, 2.0 / Float::NAN)
+ assert_float(Float::NAN, -2.0 / Float::NAN)
+ assert_float(Float::NAN, Float::INFINITY / Float::INFINITY)
+ assert_float(Float::NAN, -Float::INFINITY / Float::INFINITY)
+ assert_float(Float::NAN, Float::INFINITY / -Float::INFINITY)
+ assert_float(Float::NAN, -Float::INFINITY / -Float::INFINITY)
+ assert_float(Float::INFINITY, 1.0 / 0.0)
+ assert_float(Float::INFINITY, -1.0 / -0.0)
+ assert_float(-Float::INFINITY, 1.0 / -0.0)
+ assert_float(-Float::INFINITY, -1.0 / 0.0)
+ assert_float(0.0, 1.0 / Float::INFINITY)
+ assert_float(0.0, -1.0 / -Float::INFINITY)
+ assert_float(-0.0, -1.0 / Float::INFINITY)
+ assert_float(-0.0, 1.0 / -Float::INFINITY)
end
assert('Float#quo') do
- a = 3.123456789.quo(3.123456789)
-
- assert_float(1.0 , a)
+ assert_float(1.0, 3.123456789.quo(3.123456789))
+ assert_float(3.123456789, 3.123456789.quo(1))
+ assert_float(2.875, -5.75.quo(-2.0))
+ assert_float(-2.875, 5.75.quo(-2))
+ assert_float(-2.875, -5.75.quo(2.0))
+ assert_float(Float::NAN, 0.0.quo(0.0))
+ assert_float(Float::NAN, -0.0.quo(-0.0))
+ assert_float(Float::NAN, -0.0.quo(0.0))
+ assert_float(Float::NAN, Float::NAN.quo(Float::NAN))
+ assert_float(Float::NAN, Float::NAN.quo(0.0))
+ assert_float(Float::NAN, Float::NAN.quo(-0.0))
+ assert_float(Float::NAN, Float::NAN.quo(2.0))
+ assert_float(Float::NAN, Float::NAN.quo(-2.0))
+ assert_float(Float::NAN, 0.0.quo(Float::NAN))
+ assert_float(Float::NAN, -0.0.quo(Float::NAN))
+ assert_float(Float::NAN, 2.0.quo(Float::NAN))
+ assert_float(Float::NAN, -2.0.quo(Float::NAN))
+ assert_float(Float::NAN, Float::INFINITY.quo(Float::INFINITY))
+ assert_float(Float::NAN, -Float::INFINITY.quo(Float::INFINITY))
+ assert_float(Float::NAN, Float::INFINITY.quo(-Float::INFINITY))
+ assert_float(Float::NAN, -Float::INFINITY.quo(-Float::INFINITY))
+ assert_float(Float::INFINITY, 1.0.quo(0.0))
+ assert_float(Float::INFINITY, -1.0.quo(-0.0))
+ assert_float(-Float::INFINITY, 1.0.quo(-0.0))
+ assert_float(-Float::INFINITY, -1.0.quo(0.0))
+ assert_float(0.0, 1.0.quo(Float::INFINITY))
+ assert_float(0.0, -1.0.quo(-Float::INFINITY))
+ assert_float(-0.0, -1.0.quo(Float::INFINITY))
+ assert_float(-0.0, 1.0.quo(-Float::INFINITY))
end
assert('Float#%', '15.2.9.3.5') do

`Float::NAN/0` should be `Float::NAN`; ref a0b3378b3

#### Before this patch:

```console
$ bin/mruby -e 'p(Float::NAN/0)'
Infinity
```

#### After this patch (same as Ruby):

```console
$ bin/mruby -e 'p(Float::NAN/0)'
NaN
```