public static int hasheq(object x)
{
Type xc = x.GetType();
if (xc == typeof(long)
|| xc == typeof(int)
|| xc == typeof(short)
|| xc == typeof(byte)
|| xc == typeof(ulong)
|| xc == typeof(uint)
|| xc == typeof(ushort)
|| xc == typeof(sbyte))
{
long lpart = Util.ConvertToLong(x);
//return (int)(lpart ^ (lpart >> 32));
return Murmur3.HashLong(lpart);
}
{
// Make BigInteger conform with Int64 when in Int64 range
long lval;
BigInteger bi = x as BigInteger;
if (bi != null && bi.AsInt64(out lval))
return Murmur3.HashLong(lval);
}
if (xc == typeof(BigDecimal))
{
// stripTrailingZeros() to make all numerically equal
// BigDecimal values come out the same before calling
// hashCode. Special check for 0 because
// stripTrailingZeros() does not do anything to values
// equal to 0 with different scales.
if (isZero(x))
return BigDecimal.Zero.GetHashCode();
else
{
BigDecimal tmp = ((BigDecimal)x).StripTrailingZeros();
return tmp.GetHashCode();
}
}
return x.GetHashCode();
}