問題:
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