Here you can find the source of hash(BigDecimal bd)
public static final int hash(BigDecimal bd)
//package com.java2s; /*/*from w w w . j av a2 s. c o m*/ Copyright 2016 Goldman Sachs. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import java.math.BigDecimal; public class Main { public static final int NULL_HASH = 1048573; public static final int hash(int i, boolean isNull) { if (isNull) return NULL_HASH; return i; } public static final int hash(double d, boolean isNull) { if (isNull) return NULL_HASH; long longVal = Double.doubleToLongBits(d); return (int) (longVal ^ (longVal >>> 32)); } public static final int hash(float f, boolean isNull) { if (isNull) return NULL_HASH; return Float.floatToIntBits(f); } public static final int hash(long d, boolean isNull) { if (isNull) return NULL_HASH; return (int) (d ^ (d >>> 32)); } public static final int hash(boolean b, boolean isNull) { if (isNull) return NULL_HASH; return b ? 1231 : 1237; // to be compatible with java.lang.Boolean } public static final int hash(int i) { return i; } public static final int hash(double d) { long longVal = Double.doubleToLongBits(d); return (int) (longVal ^ (longVal >>> 32)); } public static final int hash(BigDecimal bd) { if (bd == null) return NULL_HASH; return bd.hashCode(); } public static final int hash(float f) { return Float.floatToIntBits(f); } public static final int hash(long d) { return (int) (d ^ (d >>> 32)); } public static final int hash(boolean b) { return b ? 1231 : 1237; // to be compatible with java.lang.Boolean } public static final int hash(byte[] bytes) { int len = bytes.length; int hash = 0; for (int i = 0; i < len; i++) { hash = 29 * hash + bytes[i]; } return hash; } public static final int hash(Object o) { if (o == null) return NULL_HASH; return o.hashCode(); } }