summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-compiler/core
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-01-07 18:16:27 +0900
committerGitHub <[email protected]>2019-01-07 18:16:27 +0900
commit817436c33b556ba4129ae6cf45998d51ff7b9351 (patch)
treecd72d2e92c9e9349058633fa7c62549e1c81d316 /mrbgems/mruby-compiler/core
parent89c79e56c5881831bd5c4206efa3a5e82eaf9427 (diff)
parentc8f904b7f5f53482293815822cebe7d5ac4247c1 (diff)
downloadmruby-817436c33b556ba4129ae6cf45998d51ff7b9351.tar.gz
mruby-817436c33b556ba4129ae6cf45998d51ff7b9351.zip
Merge pull request #4217 from shuujii/fix-0.0-handling
Fix `0.0` and `-0.0` handling.
Diffstat (limited to 'mrbgems/mruby-compiler/core')
-rw-r--r--mrbgems/mruby-compiler/core/codegen.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c
index b3659863b..a17272ba7 100644
--- a/mrbgems/mruby-compiler/core/codegen.c
+++ b/mrbgems/mruby-compiler/core/codegen.c
@@ -8,6 +8,7 @@
#include <limits.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#include <mruby.h>
#include <mruby/compile.h>
#include <mruby/proc.h>
@@ -566,9 +567,12 @@ new_lit(codegen_scope *s, mrb_value val)
#ifndef MRB_WITHOUT_FLOAT
case MRB_TT_FLOAT:
for (i=0; i<s->irep->plen; i++) {
+ mrb_float f1, f2;
pv = &s->irep->pool[i];
if (mrb_type(*pv) != MRB_TT_FLOAT) continue;
- if (mrb_float(*pv) == mrb_float(val)) return i;
+ f1 = mrb_float(*pv);
+ f2 = mrb_float(val);
+ if (f1 == f2 && !signbit(f1) == !signbit(f2)) return i;
}
break;
#endif