You know that you can just use real for this, right?
real
julia> real(Float64) Float64 julia> real(ComplexF64) Float64