问题:
It's well known that comparing floats for equality is a little fiddly due to rounding and precision issues.众所周知,由于舍入和精度问题,比较浮点数的相等性有点繁琐。
For example: https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/例如: https : //randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
What is the recommended way to deal with this in Python?在 Python 中处理这个问题的推荐方法是什么?
Surely there is a standard library function for this somewhere?当然在某处有一个标准库函数吗?
解决方案:
参考一: https://en.stackoom.com/question/NTcn参考二: https://stackoom.com/question/NTcn