Menu

#1 RabinHashFunction hash(byte[]) broken

open
nobody
None
5
2009-08-07
2009-08-07
No

In the method private long hash(byte[] A, int offset, int length, long ws) , one finds lines such as

^ (long) (A[s] << 56)

Unfortunately, this doesn't work correctly. The cast to (long) is not in the right place. I think you want the following instead.

^ ((long)A[s] << 56)

The problem is that the expression (A[s] << 56) is computed as an int (because A[s] is byte and 56 is an int). The original cast takes place after Java has already done the shift treating values as 32bit int.

Discussion


Log in to post a comment.