parseFloat rounding

前端 未结 5 1218
太阳男子
太阳男子 2020-12-01 12:06

I have javascript function that automatically adds input fields together, but adding numbers like 1.35 + 1.35 + 1.35 gives me an output of 4.050000000000001, just as an exam

5条回答
  •  情书的邮戳
    2020-12-01 12:32

    Instead of rounding, you may want to use the port of Java's BigDecimal to get actually precise decimal math.

提交回复
热议问题