| ▲ | lukax 10 hours ago | |
You generally want both relative and absolute tolerances. Relative handles scale, absolute handles values near zero (raw EPSILON isn’t a universal threshold per IEEE 754). The usual pattern is abs(a - b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol) to avoid both large-value and near-zero pitfalls. | ||
| ▲ | lukax 10 hours ago | parent [-] | |
See the implementation of Python's math.isclose https://github.com/python/cpython/blob/d61fcf834d197f0113a6a... | ||