int result = 1;
for (double element : a) {
long bits = Double.doubleToLongBits(element);
result = 31 * result + (int)(bits ^ (bits >>> 32));
}
return result;
}
It is textbook, but the poster asked for seemingly random numbers in code. Based on all the places the invsqrt method has popped up, it also was a textbook method for doing it quickly.
For example:
public static int hashCode(double a[])
{
if (a == null) return 0;