--- a/Float.st Thu Aug 12 10:56:06 1999 +0200
+++ b/Float.st Thu Aug 12 10:58:36 1999 +0200
@@ -865,11 +865,7 @@
hash
"return a number for hashing; redefined, since floats compare
by numeric value (i.e. 3.0 = 3), therefore 3.0 hash must be the same
- as 3 hash.
- BUG: x asFloat hash,
- x asShortFloat hash
- and x asFraction hash
- should ideally all return the same; they do not."
+ as 3 hash."
|i|
@@ -1929,6 +1925,6 @@
!Float class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Float.st,v 1.99 1999-08-12 08:55:53 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Float.st,v 1.100 1999-08-12 08:58:27 cg Exp $'
! !
Float initialize!
--- a/Fraction.st Thu Aug 12 10:56:06 1999 +0200
+++ b/Fraction.st Thu Aug 12 10:58:36 1999 +0200
@@ -479,20 +479,18 @@
hash
"return a number for hashing; redefined, since fractions compare
by numeric value (i.e. (9/3) = 3), therefore (9/3) hash must be the same
- as 3 hash.
- Ideally, I should return the same hash value as a corresponding float,
- i.e. (1/2) hash = 0.5 hash - but that seems to be too complicated
- (any idea ?)"
+ as 3 hash."
(denominator = 1) ifTrue:[^ numerator hash].
- ^ denominator hash bitXor: numerator hash
+ ^ self asFloat hash
"
3 hash
(9/3) hash
3.0 hash
(1/2) hash
+ (1/4) hash
0.0 hash
0.5 hash
0.25 hash
@@ -724,6 +722,6 @@
!Fraction class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.45 1999-08-12 08:56:06 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.46 1999-08-12 08:58:20 cg Exp $'
! !
Fraction initialize!
--- a/SFloat.st Thu Aug 12 10:56:06 1999 +0200
+++ b/SFloat.st Thu Aug 12 10:58:36 1999 +0200
@@ -590,11 +590,7 @@
hash
"return a number for hashing; redefined, since floats compare
by numeric value (i.e. 3.0 = 3), therefore 3.0 hash must be the same
- as 3 hash.
- BUG: x asFloat hash,
- x asShortFloat hash
- and x asFraction hash
- should ideally all return the same; they do not."
+ as 3 hash."
|i|
@@ -605,21 +601,17 @@
].
].
- "
- mhmh take some of my value-bits to hash on
- "
- ^ (((self basicAt:4) bitAnd:16r1F) bitShift:24) +
- ((self basicAt:3) bitShift:16) +
- ((self basicAt:2) bitShift:8) +
- (self basicAt:1)
+ ^ self asFloat hash
"
1.2345 hash
1.2345 asShortFloat hash
- 1.0 hash
+ 1.0 hash
1.0 asShortFloat hash
0.5 asShortFloat hash
0.25 asShortFloat hash
+ 0.5 hash
+ 0.25 hash
"
!
@@ -966,5 +958,5 @@
!ShortFloat class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Attic/SFloat.st,v 1.50 1999-08-12 08:55:42 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Attic/SFloat.st,v 1.51 1999-08-12 08:58:36 cg Exp $'
! !
--- a/ShortFloat.st Thu Aug 12 10:56:06 1999 +0200
+++ b/ShortFloat.st Thu Aug 12 10:58:36 1999 +0200
@@ -590,11 +590,7 @@
hash
"return a number for hashing; redefined, since floats compare
by numeric value (i.e. 3.0 = 3), therefore 3.0 hash must be the same
- as 3 hash.
- BUG: x asFloat hash,
- x asShortFloat hash
- and x asFraction hash
- should ideally all return the same; they do not."
+ as 3 hash."
|i|
@@ -605,21 +601,17 @@
].
].
- "
- mhmh take some of my value-bits to hash on
- "
- ^ (((self basicAt:4) bitAnd:16r1F) bitShift:24) +
- ((self basicAt:3) bitShift:16) +
- ((self basicAt:2) bitShift:8) +
- (self basicAt:1)
+ ^ self asFloat hash
"
1.2345 hash
1.2345 asShortFloat hash
- 1.0 hash
+ 1.0 hash
1.0 asShortFloat hash
0.5 asShortFloat hash
0.25 asShortFloat hash
+ 0.5 hash
+ 0.25 hash
"
!
@@ -966,5 +958,5 @@
!ShortFloat class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.50 1999-08-12 08:55:42 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.51 1999-08-12 08:58:36 cg Exp $'
! !