Skip to content

Commit 3e071b1

Browse files
committed
simplify
1 parent 056ecdb commit 3e071b1

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

base/rational.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ typemin(::Type{Rational{T}}) where {T<:Integer} = unsafe_rational(T, zero(T), on
262262
typemax(::Type{Rational{T}}) where {T<:Integer} = unsafe_rational(T, one(T), zero(T))
263263

264264
isinteger(x::Rational) = x.den == 1
265-
ispow2(x::Rational) = (x.den == 1 && ispow2(x.num)) || (x.num == 1 && ispow2(x.den))
265+
ispow2(x::Rational) = ispow2(x.num)) & ispow2(x.den)
266266

267267
+(x::Rational) = unsafe_rational(+x.num, x.den)
268268
-(x::Rational) = unsafe_rational(-x.num, x.den)

test/rational.jl

-1
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,6 @@ end
595595
@test -2//3 * 0x1 == 0x1 * -2//3 == -2//3
596596
end
597597

598-
599598
@testset "ispow2" begin
600599
@test ispow2(4//1)
601600
@test ispow2(1//8)

0 commit comments

Comments
 (0)