diff --git a/src/quantities.jl b/src/quantities.jl index a25863d4..7fde2b46 100644 --- a/src/quantities.jl +++ b/src/quantities.jl @@ -29,11 +29,6 @@ Quantity(x::Number, y::Units{()}) = x *(x::AbstractQuantity, y::Units, z::Units...) = Quantity(x.val, *(unit(x),y,z...)) *(x::AbstractQuantity, y::AbstractQuantity) = Quantity(x.val*y.val, unit(x)*unit(y)) -# Next two lines resolves some method ambiguity: -*(x::Bool, y::T) where {T <: AbstractQuantity} = - ifelse(x, y, ifelse(signbit(y), -zero(y), zero(y))) -*(x::AbstractQuantity, y::Bool) = Quantity(x.val*y, unit(x)) - *(y::Number, x::AbstractQuantity) = *(x,y) function *(x::AbstractQuantity, y::Number) x isa AffineQuantity && diff --git a/test/runtests.jl b/test/runtests.jl index d2012bc6..9cd426a3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -586,6 +586,12 @@ end @test @inferred((3m)*m) === 3*(m*m) # Associative multiplication @test @inferred(true*1kg) === 1kg # Boolean multiplication (T) @test @inferred(false*1kg) === 0kg # Boolean multiplication (F) + @test @inferred(true*(1+im)kg) === (1+im)kg # Boolean-complex multiplication (T) + @test @inferred(false*(1+im)kg) === (0+0im)kg # Boolean-complex multiplication (F) + @test @inferred((1+im)kg*true) === (1+im)kg # Complex-boolean multiplication (T) + @test @inferred((1+im)kg*false) === (0+0im)kg # Complex-boolean multiplication (F) + @test @inferred((NaN*kg)*false) === 0.0kg # `false` acts as "strong zero" + @test @inferred(false*(-Inf*kg)) === -0.0kg # `false` acts as "strong zero" @test typeof(one(eltype([1.0s, 1kg]))) <: Float64 # issue 159, multiplicative identity end @testset "> Division" begin