SuperChrisyang 2017-04-13 12:07 采纳率: 0%
浏览 3506

两个数值相同的BigDecimal型数字比较,为什么结果是0?与精度有关吗?

两个数值相同的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

    评论

报告相同问题?