diff --git a/src/types.jl b/src/types.jl index 840f8a6e1..2202a8df1 100644 --- a/src/types.jl +++ b/src/types.jl @@ -1143,7 +1143,7 @@ end \(a::Number, b::SN) = b / a -/(a::SN, b::Number) = (b isa Integer ? 1//b : inv(b)) * a +/(a::SN, b::Number) = (isone(abs(b)) ? b : (b isa Integer ? 1//b : inv(b))) * a //(a::Union{SN, Number}, b::SN) = a / b diff --git a/test/basics.jl b/test/basics.jl index 6dbeb9384..cc3464eab 100644 --- a/test/basics.jl +++ b/test/basics.jl @@ -301,6 +301,8 @@ end @test (2.5x/3x).num == 2.5 @test (2.5x/3x).den == 3 @test (x/3x) == 1//3 + @test isequal(x / 1, x) + @test isequal(x / -1, -x) end @testset "LiteralReal" begin