I am getting an error when dividing with Unitful but not when I multiply by the inverse of the divisor. For example:
julia> using Unitful
julia> a = 1250u"mm"
1250 mm
julia> b = (0.865:0.01:2.0)u"m";
julia> (a .+ b) .* 0.5;
julia> (a .+ b) ./ 2;
ERROR: DimensionError: m and 2 are not dimensionally compatible.
Stacktrace:
[1] convert(#unused#::Type{Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}} , x::Int64)
@ Unitful C:\Users\jakez\.julia\packages\Unitful\fbiNW\src\conversion.jl:112
[2] oftype(x::Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}} , y::Int64)
@ Base .\essentials.jl:391
[3] /(x::Base.TwicePrecision{Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}} , v::Int64)
@ Base .\twiceprecision.jl:327
[4] broadcasted(#unused#::Base.Broadcast.DefaultArrayStyle{1}, #unused#::typeof(/), r::StepRangeLen{Quantity{Float64, �,, Unitful.FreeUnits{(m,), 𝐋, nothing}}, Base.TwicePrecision{Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}
}}, Base.TwicePrecision{Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}, Int64} , x::Int64)
@ Base.Broadcast .\broadcast.jl:1135
[5] broadcasted(::Function, ::StepRangeLen{Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}, Base.TwicePreci
sion{Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}, Base.TwicePrecision{Quantity{Float64, 𝐋, Unitful.Fre
eUnits{(m,), 𝐋, nothing}}}, Int64} , ::Int64)
@ Base.Broadcast .\broadcast.jl:1304
[6] top-level scope
@ REPL[8]:1
Since I have this workaround it is not a big deal, but it does seem odd. Is there an explanation or is this a bug?