Commit f44acf7b authored by Yukihiro Matsumoto's avatar Yukihiro Matsumoto

explicit normalization -0.0 to 0.0

parent 1eb02552
...@@ -372,7 +372,8 @@ flo_hash(mrb_state *mrb, mrb_value num) ...@@ -372,7 +372,8 @@ flo_hash(mrb_state *mrb, mrb_value num)
int i, hash; int i, hash;
d = (mrb_float)mrb_fixnum(num); 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; c = (char*)&d;
for (hash=0, i=0; i<sizeof(mrb_float);i++) { for (hash=0, i=0; i<sizeof(mrb_float);i++) {
hash = (hash * 971) ^ (unsigned char)c[i]; hash = (hash * 971) ^ (unsigned char)c[i];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment