I have a range of objects that have a long field whose value uniquely identifies a particular object across my entire system, much like a GUID. I have overriden
long
int result = (int)((longVal >> 32) ^ longVal);
will be more well distributed, because modulo will not return different value if only upper bits of your long value has changed.