From: Christoph Rippel Date: 2001-03-29T23:11:03+09:00 Subject: [ruby-talk:13325] Re: A subtle Hash bug > From: Yukihiro Matsumoto [mailto:matz@zetabits.com] [...] > |If one wants to fix this one has explicitly check for the -0.0 bit pattern. > |The other possibility is to declare that > | > | -0.0.eql 0.0 # => false > | > |in which case one has to check for the -0.0 pattern in the #eql? method > |which is actually better IMO. > > The patch does the former, since it's far easier to implement. Then, > which do you think is better, community people? Well, my reason for preferring the ladder is that the combination of (-0.0 == 0.0) but (1/-0.0) != (1/0.0) seems somewhat dubious to me (also see the patch below). Since Ruby sports three ``identity'' methods it seems reasonable to ``fix'' this in the intermediate strength #eql? method. In a faster implementation I would not bother with ripping out the sign bit but rip out significant 32 (or 64) chunks but I don't think that it's really worth the trouble. Christoph [...] -------------- $ diff numeric.c numeric.c.orig 597,598c597 < if ((RFLOAT(x)->value == RFLOAT(y)->value) && ((RFLOAT(x)->value != 0) \ < || (1/(RFLOAT(x)->value)) == (1/(RFLOAT(y)->value)) )) return Qtrue; --- > if (RFLOAT(x)->value == RFLOAT(y)->value) return Qtrue;