#DOCUMENTATION by cg
authorClaus Gittinger <cg@exept.de>
Tue, 28 Nov 2017 15:11:53 +0100
changeset 22380 f21fb6440a1d
parent 22379 6ba8f68b0814
child 22381 c4270f11aaca
#DOCUMENTATION by cg class: LargeInteger comment/format in: #hash
LargeInteger.st
--- a/LargeInteger.st	Tue Nov 28 14:04:00 2017 +0100
+++ b/LargeInteger.st	Tue Nov 28 15:11:53 2017 +0100
@@ -2223,13 +2223,19 @@
 
     sz := digitByteArray size.
     (sz <= SmallInteger maxBytes and:[self absLess:SmallInteger maxVal]) ifTrue:[
-	"I am really an unnormalized SmallInteger, answer the same hash as for the SmallInteger"
-	^ self bitAnd:SmallInteger maxVal.
+        "I am really an unnormalized SmallInteger, answer the same hash as for the SmallInteger"
+        ^ self bitAnd:SmallInteger maxVal.
     ].
 
     h := digitByteArray computeXorHashFrom:1 to:8.                  "/ the low 8 bytes
     sz > 8 ifTrue:[                                                 "/ the high 8 bytes
-	h := h bitXor:(digitByteArray computeXorHashFrom:sz-8 to:sz).
+        "/ the code below is actually not doing what was intended 
+        "/ (to take the hashes of the last 8 bytes)
+        "/ It does actually take the last 9 bytes (due to a mistake of the original programmer...)
+        "/ However, we will not change it, but keep it that way, in case the hashvalue already found
+        "/ its way into some dictionary (as key-index).
+        "/ It does not really hurt anyway, so there is no need to change it.
+        h := h bitXor:(digitByteArray computeXorHashFrom:sz-8 to:sz).
     ].
     ^ h
 
@@ -2244,6 +2250,8 @@
      16r800000000000000000008 hash
      16r-800000000000000000008 hash
     "
+
+    "Modified (format): / 28-11-2017 / 15:04:59 / cg"
 !
 
 hashMultiply