Primitive Type
HashCode
How String hashCode is calculated?
s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]Parity
Giving a binary word, if the number of 1s is odd, return 1, otherwise 0
(11010111) => (1101)^(0111)
public static short parity(long x) {
x ^= (x >>> 32);
x ^= (x >>> 16);
x ^= (x >>> 8);
x ^= (x >>> 4);
x ^= (x >>> 2);
x ^= (x >>> 1);
return (short) (x & 1);
}50 Compute x^y
Last updated
Was this helpful?