explicit normalization -0.0 to 0.0

This commit is contained in:
Yukihiro Matsumoto
2012-05-23 02:18:40 +09:00
parent 1eb02552ea
commit f44acf7bf8
+2 -1
View File
@@ -372,7 +372,8 @@ flo_hash(mrb_state *mrb, mrb_value num)
int i, hash;
d = (mrb_float)mrb_fixnum(num);
if (d == 0) d = fabs(d);
/* normalize -0.0 to 0.0 */
if (d == 0) d = 0.0;
c = (char*)&d;
for (hash=0, i=0; i<sizeof(mrb_float);i++) {
hash = (hash * 971) ^ (unsigned char)c[i];