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

Converting inverse units fails

Open jariji opened this issue 1 year ago β€’ 2 comments

julia> uconvert(u"1/km", 3.0u"1/m")
ERROR: MethodError: no method matching uconvert(::Quantity{Int64, 𝐋^-1, Unitful.FreeUnits{(km^-1,), 𝐋^-1, nothing}}, ::Quantity{Float64, 𝐋^-1, Unitful.FreeUnits{(m^-1,), 𝐋^-1, nothing}})

Is this supposed to work? Why not?

jariji avatar May 13 '24 00:05 jariji

This doesn’t work because u"1/km" is a quantity, not a unit. You can use u"km^-1" instead.

sostock avatar May 13 '24 07:05 sostock

Thanks.

An error-message hint (Base.Experimental.register_error_hint) might be helpful here.

jariji avatar May 13 '24 07:05 jariji