Round methods for Complex


#1

To me it seems that there are some round methods missing in Base

julia> round(Complex64, Complex(0, 1.0))
ERROR: MethodError: no method matching round(::Type{Complex{Float32}}, ::Complex{Float64})

Shouldn’t there be something like ?

round(::Type{Complex{T}}, x::Complex{U}) where U<:Real where T<:Real = Complex{T}(round(T, x.re), round(T, x.im))

I am running julia 0.6


#2

This isn’t specific to Complex:

julia> round(Float32, 1.0)
ERROR: MethodError: no method matching round(::Type{Float32}, ::Float64)
Closest candidates are:
  round(::Type{T<:Integer}, ::AbstractFloat) where T<:Integer at float.jl:337
  round(::Type{T}, ::Rational{Bool}) where T at rational.jl:403
  round(::Type{T}, ::Rational{Bool}, ::RoundingMode{:Nearest}) where T at rational.jl:409
  ...

julia> round(Float64, 1.0)
ERROR: MethodError: no method matching round(::Type{Float64}, ::Float64)
Closest candidates are:
  round(::Type{T<:Integer}, ::AbstractFloat) where T<:Integer at float.jl:337
  round(::Type{T}, ::Rational{Bool}) where T at rational.jl:403
  round(::Type{T}, ::Rational{Bool}, ::RoundingMode{:Nearest}) where T at rational.jl:409
  ...

#3

Could definitely use an issue for a feature request.