Value for epsilon in Python

后端 未结 4 945
夕颜
夕颜 2020-12-08 09:09

Is there a standard value for (or method for obtaining) epsilon in Python? I need to compare floating point values and want to compare against the smallest possible differen

4条回答
  •  春和景丽
    2020-12-08 09:38

    The information is available in sys.float_info, which corresponds to float.h in C99.

    >>> import sys
    >>> sys.float_info.epsilon
    2.220446049250313e-16
    

提交回复
热议问题