Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Sep 17, 2020
1 parent 056ecdb commit 3e071b1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 1 addition & 1 deletion base/rational.jl
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ typemin(::Type{Rational{T}}) where {T<:Integer} = unsafe_rational(T, zero(T), on
typemax(::Type{Rational{T}}) where {T<:Integer} = unsafe_rational(T, one(T), zero(T))

isinteger(x::Rational) = x.den == 1
ispow2(x::Rational) = (x.den == 1 && ispow2(x.num)) || (x.num == 1 && ispow2(x.den))
ispow2(x::Rational) = ispow2(x.num)) & ispow2(x.den)

+(x::Rational) = unsafe_rational(+x.num, x.den)
-(x::Rational) = unsafe_rational(-x.num, x.den)
Expand Down
1 change: 0 additions & 1 deletion test/rational.jl
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,6 @@ end
@test -2//3 * 0x1 == 0x1 * -2//3 == -2//3
end


@testset "ispow2" begin
@test ispow2(4//1)
@test ispow2(1//8)
Expand Down

0 comments on commit 3e071b1

Please sign in to comment.