Here you can find the source of isSameValue(final BigDecimal val1, final BigDecimal val2)
public static boolean isSameValue(final BigDecimal val1, final BigDecimal val2)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; public class Main { /**/*from w ww . j a va 2 s .co m*/ * @return true if val1 == val2 (ignoring scale and null are treated as 0) */ public static boolean isSameValue(final BigDecimal val1, final BigDecimal val2) { return val1 == null && val2 == null || val1 != null && val2 != null && val1.compareTo(val2) == 0; } /** * @return 1 if v1 > v2 or v2==null and v2!=null * @return 0 if v1 == v2 or v1==null and v2==null * @return -1 if v1 < v2 or v1==null and v2!=null */ public static int compareTo(final BigDecimal v1, final BigDecimal v2) { int ret = 1; if (v1 != null && v2 != null) { ret = v1.compareTo(v2); } else if (v1 == null && v2 == null) { ret = 0; } else if (v1 == null) { ret = -1; } return ret; } }