Math Functions
math.isclose()
Compare real values using relative and absolute tolerances. NaN is never close; infinities only match themselves. Use absolute tolerance near zero.
Formal Syntax & Structure
python syntaxpython
math.isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| a | real number | First value to compare. |
| b | real number | Second value to compare. |
| rel_tol | float | Nonnegative relative comparison tolerance. |
| abs_tol | float | Nonnegative absolute comparison tolerance. |
Return Value
bool
True when the described condition holds, otherwise False.
Working Example
Example Snippetpython
import mathprint(math.isclose(0.1 + 0.2, 0.3))