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

后端 未结 3 707
暗喜
暗喜 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 16:48

    Yes, this is a common floating-point format issue.

    0 讨论(0)
  • 2021-01-15 17:02

    Why do computers suck at math?

    http://www.codinghorror.com/blog/archives/001266.html

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题