Skip to content

Commit

Permalink
Merge pull request #585 from JuliaSymbolics/myb/op
Browse files Browse the repository at this point in the history
Simplify the construction of `x / 1` and `x / -1`
  • Loading branch information
YingboMa authored Mar 11, 2024
2 parents d68e092 + d2521fe commit 3efca84
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions test/basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3efca84

Please sign in to comment.