Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
为什么
2.23 + 0.17 = 2.4899999999999998
但
1.23 + 0.17 = 1.49
调试控制台的屏幕截图:
这是浮点数的魔力:)
你可以阅读一些关于它的有趣的东西。此外,还有针对这些问题的解决方案。