summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-23 17:01:17 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-23 17:01:17 +0000
commitc758d63138e20d8bcc9f55e36dac1f2757e6eedb (patch)
treec98f219bab61e781eb4e8f111fd01efe1dfb5fc7 /hash.c
parentc5a691323201ace5f5299b6914c8e1709918c521 (diff)
merge revision(s) 49999,50000: [Backport #10979]
* hash.c (rb_any_hash): use same hash values with Float#hash so that -0.0 and +0.0 will be identical. [ruby-core:68541] [Bug #10979] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@50619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/hash.c b/hash.c
index 8d37dc6368..3ef0ed458f 100644
--- a/hash.c
+++ b/hash.c
@@ -142,13 +142,16 @@ rb_any_hash(VALUE a)
}
else if (FLONUM_P(a)) {
/* prevent pathological behavior: [Bug #10761] */
- a = (st_index_t)rb_float_value(a);
+ return rb_dbl_hash(rb_float_value(a));
}
hnum = rb_objid_hash((st_index_t)a);
}
else if (BUILTIN_TYPE(a) == T_STRING) {
hnum = rb_str_hash(a);
}
+ else if (BUILTIN_TYPE(a) == T_FLOAT) {
+ return rb_dbl_hash(rb_float_value(a));
+ }
else {
hval = rb_hash(a);
hnum = FIX2LONG(hval);