Python Decimal模块用于浮点数比较的核心适用场景咨询
Python Decimal模块用于浮点数比较的核心适用场景咨询
Recently I got to know the decimal python module. While I got to understand how to work with this, I still have a question that persists:
What is/are the main case(s) where coders should use decimal.Decimal for float comparison?
For example, in the past I have already performed some automatic tests for installable packages. In these, I always performed the comparison among floats with pytest.approx() or by comparing the absolute difference with an epsilon value.
Maybe my experience is still not enough to see which cases the decimal module is better. Could anyone provide some insights to me?
备注:内容来源于stack exchange,提问作者Jaime
相关产品推荐
相关产品推荐

