BigDecimal类型比较大小

if (a.compareTo(b) == -1) {
System.out.println("a小于b");
}
if (a.compareTo(b) == 0) {
System.out.println("a等于b");
}
if (a.compareTo(b) == 1) {
System.out.println("a大于b");
}
if (a.compareTo(b) > -1) {
System.out.println("a大于等于b");
}
if (a.compareTo(b) < 1) {
System.out.println("a小于等于b");
}
posted @ 2022-06-02 17:15  懂得归零  阅读(45)  评论(0编辑  收藏  举报