On 12/13/2016 08:39 AM, Andres Valloud wrote:
> I would have expected the floats to be a byte object of size 8.  Why is
> this conversion needed?  Is somehow the primitive thinking the float has
> size 2?  Or is the primitive hashing 32 bits at a time?  The prim used
> to be a C version of the byte oriented 1644525 multiplicative hash, did
> this change?

The float is not a byte object of size 8, it's a word object of size 2.

When you feed it to #hashBytes:startingWith: the primitive fails. (I
didn't look at why -- maybe because it isn't a byte object?)

The alternative Smalltalk code treats it like it was a byte object, even
though it's not. So it iterates through the two words, multiplying each
by 1664525, then keeping only the low-order 28 bits of the result. But
since each word is a full 32 bits, the high-order four bits of each
word, which include the sign bit, can never affect the hash.

Regards,

-Martin

Reply via email to