fix(ccint): make sure hash is always positive

This commit is contained in:
Simon Cruanes 2021-04-03 00:57:41 -04:00
parent cc7799f379
commit 7717cc13db

View file

@ -49,7 +49,7 @@ let hash (n:int) : int =
(* h := h xor (k-th bit of n) *) (* h := h xor (k-th bit of n) *)
h := Int64.(logxor !h (of_int ((n lsr (k * 8)) land 0xff))); h := Int64.(logxor !h (of_int ((n lsr (k * 8)) land 0xff)));
done; done;
Int64.to_int !h (* truncate back to int *) (Int64.to_int !h) land max_int (* truncate back to int and remove sign *)
let range i j yield = let range i j yield =
let rec up i j yield = let rec up i j yield =