summaryrefslogtreecommitdiffhomepage
path: root/src/etc.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-08-10 08:36:09 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-08-10 08:36:09 +0900
commit78be0172f74e2bf109f7a216e43257ba3eb8ecc4 (patch)
tree587ea3fb506057b349ddbd860a762295b59fc8cc /src/etc.c
parent9826ca54f275787cc2338679353df22961ae87b5 (diff)
downloadmruby-78be0172f74e2bf109f7a216e43257ba3eb8ecc4.tar.gz
mruby-78be0172f74e2bf109f7a216e43257ba3eb8ecc4.zip
Normalize float numbers before calculating a hash value.
Diffstat (limited to 'src/etc.c')
-rw-r--r--src/etc.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/etc.c b/src/etc.c
index e0810d589..9475ae304 100644
--- a/src/etc.c
+++ b/src/etc.c
@@ -93,6 +93,8 @@ mrb_float_id(mrb_float f)
int len = sizeof(f);
mrb_int id = 0;
+ /* normalize -0.0 to 0.0 */
+ if (f == 0) f = 0.0;
while (len--) {
id = id*65599 + *p;
p++;