diff --git a/src/types.jl b/src/types.jl index 92ecdc46..8f6cd32b 100644 --- a/src/types.jl +++ b/src/types.jl @@ -669,7 +669,7 @@ function Div{T}(n, d, simplified=false; metadata=nothing, kwargs...) where {T} end d isa Number && _isone(-d) && return -1 * n - n isa Rat && d isa Rat && return n // d # maybe called by oblivious code in simplify + !(n isa AbstractFloat) && d isa Rat && return n * (1 // d) # maybe called by oblivious code in simplify # GCD coefficient upon construction rat, nc = ratcoeff(n) diff --git a/test/basics.jl b/test/basics.jl index 60e09e4f..5854aaec 100644 --- a/test/basics.jl +++ b/test/basics.jl @@ -368,6 +368,8 @@ end @test (2x/3y).num.coeff == 2 @test (2x/3y).den.coeff == 3 @test (2x/-3x) == -2//3 + @test isequal((2x*y/-3x), -2y/3) + @test isequal((x*y/2x), y/2) @test (2.5x/3x).num == 2.5 @test (2.5x/3x).den == 3 @test (x/3x) == 1//3