# Approx test of two real numbers

**URL:** <https://discourse.julialang.org/t/approx-test-of-two-real-numbers/5504>\
**Category:** General Usage\
**Created:** [August 22, 2017, 1:48pm UTC](https://discourse.julialang.org/t/approx-test-of-two-real-numbers/5504 "2017-08-22T13:48:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Post date:** [August 22, 2017, 1:48pm UTC](https://discourse.julialang.org/t/approx-test-of-two-real-numbers/5504/1 "2017-08-22T13:48:54Z")

</div>

I find it confusing that this passes the test

```julia
julia> @test 1.0+1e-10 ≈ 1.0 atol=1e-15
Test Passed

```

because `rtol` is set to `sqrt(eps)`, whereas for the correct test I need to write the “ugly” version ([manual wording](https://docs.julialang.org/en/latest/stdlib/test/#Testing-Base-Julia-1))

```julia
julia> @test ≈(1.0+1e-10, 1.0, atol=1e-15, rtol=0.0)
Test Failed
  Expression: ≈(1.0 + 1.0e-10, 1.0, atol=1.0e-15, rtol=0.0)
ERROR: There was an error during testing

```

Is there a way of adding the `rtol` parameter to the `nice` syntax version?

---

<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:** [August 22, 2017, 2:10pm UTC](https://discourse.julialang.org/t/approx-test-of-two-real-numbers/5504/2 "2017-08-22T14:10:32Z")

</div>

I think you want `@test 1.0+1e-10 ≈ 1.0 atol=1e-15 rtol=0`?

In 0.7, setting `atol>0` will make `rtol` default to 0 ([https://github.com/JuliaLang/julia/pull/22742](https://github.com/JuliaLang/julia/pull/22742)).

---

<div class="post-metadata">

**Author:** ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Post date:** [August 22, 2017, 4:20pm UTC](https://discourse.julialang.org/t/approx-test-of-two-real-numbers/5504/3 "2017-08-22T16:20:40Z")

</div>

Ah, I wanted to add this to the manual, but the master version is completely different…
