Last active
December 23, 2019 18:16
-
-
Save netstart/ed2f13963993b1abc05d to your computer and use it in GitHub Desktop.
BigDecimalUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BigDecimalUtil { | |
public static int compareToIgnoreSignal(BigDecimal a, BigDecimal b) { | |
if (a.signum() < 0) a = a.multiply(new BigDecimal(-1)); | |
if (b.signum() < 0) b = b.multiply(new BigDecimal(-1)); | |
return a.compareTo(b); | |
} | |
public static Boolean isMinorThanIgnoreSignal(BigDecimal a, BigDecimal b) { | |
return compareToIgnoreSignal(a, b) < 0; | |
} | |
public static Boolean isGraterThanIgnoreSignal(BigDecimal a, BigDecimal b) { | |
return compareToIgnoreSignal(a, b) > 0; | |
} | |
public static Boolean isEqualsIgnoreSignal(BigDecimal a, BigDecimal b) { | |
return compareToIgnoreSignal(a, b) == 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment