Unitful.jl icon indicating copy to clipboard operation
Unitful.jl copied to clipboard

Promotion in integer array

Open HaoxuanGuo opened this issue 3 years ago • 0 comments

promote([1u"kg"], [2u"g"])      # will give an error
promote([1.0u"kg"], [2.0u"g"])  # no error

Because promotion in Integer gives a Rational.

Code from Base (call stack)

promote_rule(a::Type{Array{T,n}}, b::Type{Array{S,n}}) where {T,n,S} = el_same(promote_type(T,S), a, b)  # array.jl
el_same(::Type, a, b) = promote_typejoin(a, b)  # range.jl

A new promote_typejoin may have been define?

HaoxuanGuo avatar Dec 14 '21 18:12 HaoxuanGuo