推广部分大改

This commit is contained in:
liuyingfang
2023-07-21 19:30:00 +08:00
parent bfba38e27b
commit d4fe97d570
25 changed files with 805 additions and 58 deletions

View File

@@ -0,0 +1,47 @@
package cn.pluss.platform.util;
import java.math.BigDecimal;
import static java.math.BigDecimal.ROUND_DOWN;
public class N {
public static final int SCALE = 6;
public static final boolean isZero(BigDecimal num) {
return num == null || BigDecimal.ZERO.compareTo(num) == 0;
}
public static final boolean isNull(BigDecimal num) {
return num == null;
}
public static final boolean eq(BigDecimal n1, BigDecimal n2) {
return (!isNull(n1) && !isNull(n2) && n1.compareTo(n2) == 0);//n1==n2
}
public static final boolean gt(BigDecimal n1, BigDecimal n2) {
return (!isNull(n1) && !isNull(n2) && n1.compareTo(n2) > 0);//n1>n2
}
public static final boolean egt(BigDecimal n1, BigDecimal n2) {
return (!isNull(n1) && !isNull(n2) && n1.compareTo(n2) >= 0);
}
public static final BigDecimal mul(BigDecimal b1, BigDecimal b2) {
if (isNull(b1) || isNull(b2))
throw new IllegalArgumentException();
return b1.multiply(b2).setScale(SCALE, ROUND_DOWN);
}
public static final BigDecimal div(BigDecimal b1, BigDecimal b2) {
if (isNull(b1) || isZero(b2))
throw new IllegalArgumentException();
return b1.divide(b2, SCALE, ROUND_DOWN);
}
}