两个数值相同的BigDecimal型数字比较,为什么结果是0?与精度有关吗?
3条回答 默认 最新
战在春秋 2017-04-13 12:22关注如果用的是compareTo方法,比如res = bg1.compareTo(bg2); 那么两数相等其返回值应该为0
引自官方文档:
This method returns -1 if the BigDecimal is less than val, 1 if the BigDecimal is greater than val and 0 if the BigDecimal is equal to val
解决 无用评论 打赏 举报