Norm of Number type I define

You don’t need to implement conversion to Float64, you only need to implement promotion with Float64. e.g.

Base.promote_rule(::Type{My}, ::Type{Float64}) = My

(The reason for this is that norm needs to promote any type to a floating-point type for accumulation, and for accuracy/overflow reasons asks you to promote to at least double precision.)

You’ll also want:

Base.float(x::My) = x

(My is already a floating-point type … more generally, if you had My{T} then you want to convert to My{float(T)}).

2 Likes