# Approx with a weird behaviour

**URL:** https://discourse.julialang.org/t/approx-with-a-weird-behaviour/19690
**Category:** General Usage
**Created:** [January 16, 2019, 11:48am UTC](https://discourse.julialang.org/t/approx-with-a-weird-behaviour/19690 "2019-01-16T11:48:52Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![IljaK91](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iljak91/32/44301_2.png) [@IljaK91](https://discourse.julialang.org/u/IljaK91)
#### Post date: [January 16, 2019, 11:48am UTC](https://discourse.julialang.org/t/approx-with-a-weird-behaviour/19690/1 "2019-01-16T11:48:52Z")

</div>

Why do these two statements give me different results? The first is `false`, the second is `true`.

```julia
0.0 ≈ 1.071327271687239e-17
1.0 ≈ 1.0 + 1.071327271687239e-17

```

---

<div class="post-metadata">

### Author: ![bennedich](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bennedich/32/4894_2.png) [@bennedich](https://discourse.julialang.org/u/bennedich)
#### Post date: [January 16, 2019, 12:04pm UTC](https://discourse.julialang.org/t/approx-with-a-weird-behaviour/19690/2 "2019-01-16T12:04:43Z")

</div>

The [documentation](https://docs.julialang.org/en/latest/base/math/#Base.isapprox) might be helpful. Or the implementation:

```julia
julia> @less 0 ≈ 1.071327271687239e-17

function isapprox(x::Number, y::Number; atol::Real=0, rtol::Real=rtoldefault(x,y,atol), nans::Bool=false)
    x == y || (isfinite(x) && isfinite(y) && abs(x-y) <= max(atol, rtol*max(abs(x), abs(y)))) || (nans && isnan(x) && isnan(y))
end

```

Also note that:

```julia
julia> 1.0 + 1.071327271687239e-17
1.0

```
