From 6731f935cc0460852ab36a21aaacd5e30d6b4842 Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Thu, 18 Mar 2021 17:10:51 +0900 Subject: `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 ``` --- src/numeric.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') 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; } } -- cgit v1.2.3