diff options
| author | KOBAYASHI Shuji <[email protected]> | 2021-03-18 17:10:51 +0900 |
|---|---|---|
| committer | KOBAYASHI Shuji <[email protected]> | 2021-03-18 17:10:51 +0900 |
| commit | 6731f935cc0460852ab36a21aaacd5e30d6b4842 (patch) | |
| tree | 33762f7cc1a19b420e90b8898c3a7107360b5b48 /src/numeric.c | |
| parent | a0b3378b360b0ac2d2f2b80502fb88e01516cc08 (diff) | |
| download | mruby-6731f935cc0460852ab36a21aaacd5e30d6b4842.tar.gz mruby-6731f935cc0460852ab36a21aaacd5e30d6b4842.zip | |
`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
```
Diffstat (limited to 'src/numeric.c')
| -rw-r--r-- | src/numeric.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/numeric.c b/src/numeric.c index 51137d45b..c536f0614 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -25,7 +25,6 @@ #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; } } |
