Why does JSP/JSTL division by 1000 sometimes give remainder?

后端 未结 3 708
暗喜
暗喜 2021-01-15 16:14

When dividing by 1000 I sometime run across a bug that doesn\'t do the division \"correctly\". For example, when dividing 90.55 by 1000 instead of getting .09055 I get .090

3条回答
  •  走了就别回头了
    2021-01-15 17:09

    It's not a problem, it's just a natural result of the binary representation of floating point. Round your values and don't worry about it.

提交回复
热议问题