首页 > 其他分享 >BigDecimal类型的值比较大小

BigDecimal类型的值比较大小

时间:2022-12-02 09:33:29浏览次数:39  
标签:BigDecimal skuReductionTo 大小 bigdemical2 result compareTo 类型 bigdemical1

使用compareTo方法:

eg1:
int result = bigdemical1.compareTo(bigdemical2)
result = -1,表示bigdemical1小于bigdemical2;
result = 0,表示bigdemical1等于bigdemical2;
result = 1,表示bigdemical1大于bigdemical2;

也可以直接和1进行比较:

eg2:

if(skuReductionTo.getFullCount() > 0 || skuReductionTo.getFullPrice().compareTo(new BigDecimal("0")) == 1) {
     R r1 = couponFeignService.saveSkuReduction(skuReductionTo);
     if(r1.getCode() != 0) {
         log.error("远程保存sku优惠信息失败");
  }
}

标签:BigDecimal,skuReductionTo,大小,bigdemical2,result,compareTo,类型,bigdemical1
From: https://www.cnblogs.com/sensenh/p/16943417.html

相关文章