# \`eps()\` (epsilon) for Complex floats?

**URL:** <https://discourse.julialang.org/t/eps-epsilon-for-complex-floats/59603>\
**Category:** Internals & Design\
**Tags:** question\
**Created:** [April 19, 2021, 6:18pm UTC](https://discourse.julialang.org/t/eps-epsilon-for-complex-floats/59603 "2021-04-19T18:18:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JeffFessler](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jefffessler/32/6650_2.png) [@JeffFessler](https://discourse.julialang.org/u/JeffFessler)\
**Post date:** [April 19, 2021, 6:18pm UTC](https://discourse.julialang.org/t/eps-epsilon-for-complex-floats/59603/1 "2021-04-19T18:18:40Z")

</div>

It is surprising to me that `eps(Complex{Float32})` is unsupported currently, given that there are many applications involving complex data where one would like to specify the precision of some operation appropriately.

A single line addition to Base will address this:

`eps(::Type{Complex{T}}) where T <: AbstractFloat = eps(T)`

I realize that the docs for `eps` refer to “next largest value” and there is no ordering of complex numbers, but the principle applies adequately to the real and imaginary parts.

I can submit a PR to add this one line (and associated tests and docs) but I wanted to first get a sense of whether this addition seems appropriate to others.

BTW, in Matlab `eps(1 + 1i)` works and returns the same value as `eps(1)` so I think I’m not too far out on a limb here…

I’ve seen at least two package issues that arose due to this absence:  
[https://github.com/JuliaLang/julia/issues/34866](https://github.com/JuliaLang/julia/issues/34866)  
[https://github.com/SciML/DifferentialEquations.jl/issues/287](https://github.com/SciML/DifferentialEquations.jl/issues/287)

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [April 19, 2021, 6:32pm UTC](https://discourse.julialang.org/t/eps-epsilon-for-complex-floats/59603/2 "2021-04-19T18:32:54Z")

</div>

Yeah. This is kind of weird. On the balance, it sounds like we should support this. Want to make a PR?

---

<div class="post-metadata">

**Author:** ![JeffFessler](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jefffessler/32/6650_2.png) [@JeffFessler](https://discourse.julialang.org/u/JeffFessler)\
**Post date:** [April 19, 2021, 8:16pm UTC](https://discourse.julialang.org/t/eps-epsilon-for-complex-floats/59603/3 "2021-04-19T20:16:43Z")

</div>

edit: so much for it being just one added line 🙂

---

<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:** [April 19, 2021, 8:55pm UTC](https://discourse.julialang.org/t/eps-epsilon-for-complex-floats/59603/4 "2021-04-19T20:55:10Z")

</div>

There is already a PR: [Support complex numbers in eps by ChrisRackauckas · Pull Request #21858 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/21858)

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [June 17, 2021, 5:23pm UTC](https://discourse.julialang.org/t/eps-epsilon-for-complex-floats/59603/5 "2021-06-17T17:23:40Z")

</div>

Yeah, this is exactly what brought it up, but I never got back to it. I don’t know when I’ll have the time to revive the PR either, so assume it’s open and take a stab at it if you want. It’s probably only like an hour or two away: just move some tests, make a small change, and make it a branch off of latest master.
