Skip to content

Commit

Permalink
Merge 24250a8 into 9ba45f8
Browse files Browse the repository at this point in the history
  • Loading branch information
w-vdh committed Jan 7, 2021
2 parents 9ba45f8 + 24250a8 commit dde607b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/RationalRoots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ for op in (:*, :/, :\, ://)
signedroot($op(signedsquare(x), signedsquare(y)))
end

# When squared, return Rational type:
Base.literal_pow(::typeof(^), x::RationalRoot, ::Val{2}) = abs(x.signedsquare)

Base.inv(x::RationalRoot) = signedroot(inv(signedsquare(x)))

Base.one(x::RationalRoot) = one(typeof(x))
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ end
@test iszero(zero(x))
@test !isone(zero(x))
@test zero(x) * x === zero(x)
@test x^2 === abs(a)
end
end

Expand Down

0 comments on commit dde607b

Please sign in to comment.