# Bug with isapprox?

**URL:** <https://discourse.julialang.org/t/bug-with-isapprox/7600>\
**Category:** General Usage\
**Created:** [December 7, 2017, 10:32am UTC](https://discourse.julialang.org/t/bug-with-isapprox/7600 "2017-12-07T10:32:06Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [December 7, 2017, 1:32pm UTC](https://discourse.julialang.org/t/bug-with-isapprox/7600/5 "2017-12-07T13:32:55Z")

</div>

This has nothing to do with the value of `eps(0.0)`. `x ≈ 0.0` will always give `false` for `x ≠ 0`, because `≈` tests only _relative_ error. If `x ≠ 0`, then _no_ significant digits of `x` match `0.0`, so the result of `x ≈ 0.0` is `false`.

In particular, `x ≈ y` tests `norm(x-y) ≤ sqrt(eps(T))*max(norm(x),norm(y))` with `T=typeof(real(x-y))`, which tests whether about half of the significant digits match.

If you call `isapprox(x,y)` explicitly, you can pass an `atol` argument to instead pass an _absolute_ tolerance, i.e. to test whether `norm(x-y) ≤ atol`. But since there is no reasonable way to pick a default value of `atol` (it is dimensionful, i.e. it depends on the _scale_ of `x` and `y`), using `≈` sets `atol` to zero.

Note that `1.0 - 1e-10 ≈ 1.0` gives `true`, because more than half of the significant digits match `1.0`.

---

_[View the full topic](https://discourse.julialang.org/t/bug-with-isapprox/7600)._
