# How to get the base type of a \`Complex\`

**URL:** <https://discourse.julialang.org/t/how-to-get-the-base-type-of-a-complex/79658>\
**Category:** New to Julia\
**Created:** [April 18, 2022, 9:18pm UTC](https://discourse.julialang.org/t/how-to-get-the-base-type-of-a-complex/79658 "2022-04-18T21:18:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [April 18, 2022, 9:18pm UTC](https://discourse.julialang.org/t/how-to-get-the-base-type-of-a-complex/79658/1 "2022-04-18T21:18:42Z")

</div>

Hi, here is what I have

```julia
realtype(::Type{T}) where {T<:Real} = T
realtype(::Type{Complex{T}}) where {T<:Real} = T

```

I wonder if there is a recommended (`Base`-y) way to do this? Thanks!

---

<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 18, 2022, 9:49pm UTC](https://discourse.julialang.org/t/how-to-get-the-base-type-of-a-complex/79658/2 "2022-04-18T21:49:27Z")

</div>

> [@goerch](#):
>
> Hi, here is what I have
> 
> ```julia
> realtype(::Type{T}) where {T<:Real} = T
> 
> ```

You know that you can just use `real` for this, right?

```julia
julia> real(Float64)
Float64

julia> real(ComplexF64)
Float64

```
