help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] BUG gst2.2: Fraction hash


From: nicolas cellier
Subject: [Help-smalltalk] BUG gst2.2: Fraction hash
Date: Sat, 27 Jan 2007 03:47:38 +0100
User-agent: Thunderbird 1.5.0.4 (X11/20060516)


Fraction>>hash does inline Fraction as Float with a different algorithm
than Fraction>>asFloat...

Consequently, when numerator and/or denominator grows big, a bug appears:

| xFrac xFloat |
xFrac := 9/10 raisedToInteger: 400.
xFloat = xFrac asFloatD.
xFrac hash = xFloat hash

xFrac and xFloat will answer true to equality (this is arguable, because
only their floating point approximation are equal, not their
exactFraction representation, but this is another thread).

But their hash code will not be equal... Bad thing for Set and
Dictionary mixing Fraction and Float...


Nicolas Cellier





reply via email to

[Prev in Thread] Current Thread [Next in Thread]