summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-28 00:54:19 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-28 00:54:19 +0000
commited737b87d46521e5bf082138f251eb3018966821 (patch)
tree57417318d6f1a03dcf075e15920c113eadf318a3 /numeric.c
parent3a312317e68a8365edbd71cda5729c3d08d27bbb (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_1@50655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/numeric.c b/numeric.c
index b7a4e968ef..c463732c08 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1110,10 +1110,14 @@ flo_eq(VALUE x, VALUE y)
static VALUE
flo_hash(VALUE num)
{
- double d;
+ return rb_dbl_hash(RFLOAT_VALUE(num));
+}
+
+VALUE
+rb_dbl_hash(double d)
+{
st_index_t hash;
- d = RFLOAT_VALUE(num);
/* normalize -0.0 to 0.0 */
if (d == 0.0) d = 0.0;
hash = rb_memhash(&d, sizeof(d));