T
Thomas B.
Hello. I just found a bug in Ruby, version 1.9.1p0, Windows.
In the rdoc to Object#hash we read
(http://ruby-doc.org/core/classes/Object.html#M000337):
"This function must have the property that a.eql?(b) implies a.hash ==
b.hash."
Now see:
irb(main):214:0> z=0.0
=> 0.0
irb(main):215:0> nz=-0.0
=> -0.0
irb(main):216:0> z.eql?(nz)
=> true
irb(main):217:0> z.hash
=> 1041500564
irb(main):218:0> nz.hash
=> -434138511
So the class Float does not fully follow the #hash contract. Well, isn't
that strange?
TPR.
In the rdoc to Object#hash we read
(http://ruby-doc.org/core/classes/Object.html#M000337):
"This function must have the property that a.eql?(b) implies a.hash ==
b.hash."
Now see:
irb(main):214:0> z=0.0
=> 0.0
irb(main):215:0> nz=-0.0
=> -0.0
irb(main):216:0> z.eql?(nz)
=> true
irb(main):217:0> z.hash
=> 1041500564
irb(main):218:0> nz.hash
=> -434138511
So the class Float does not fully follow the #hash contract. Well, isn't
that strange?
TPR.