Node: 25.6-0.15 计算出错,类似的应该还有许多

Created on 20 Jun 2019  Â·  1Comment  Â·  Source: nodejs/node

  • Version:
  • Platform:
  • Subsystem:
question

Most helpful comment

There is no calculation error, what you're seeing is the result of JavaScript's use of IEEE-754 floating point for its number type. If you are expecting a result like 25.45 you will need to use a third party library that implements that kind of behavior. There are such "BigDecimal"-type libraries publicly available online for this kind of purpose (in addition to allowing larger values in general).

>All comments

There is no calculation error, what you're seeing is the result of JavaScript's use of IEEE-754 floating point for its number type. If you are expecting a result like 25.45 you will need to use a third party library that implements that kind of behavior. There are such "BigDecimal"-type libraries publicly available online for this kind of purpose (in addition to allowing larger values in general).

Was this page helpful?
0 / 5 - 0 ratings