diff --git a/src/Static.jl b/src/Static.jl index 00e4bcf..6db19a2 100644 --- a/src/Static.jl +++ b/src/Static.jl @@ -447,6 +447,9 @@ Base.div(::StaticNumber{X}, y::Real, m::RoundingMode) where {X} = div(X, y, m) Base.div(x::StaticBool, y::False) = throw(DivideError()) Base.div(x::StaticBool, y::True) = x +Base.rem(::Integer, y::One) = Zero() +Base.rem(::Integer, y::StaticInt{-1}) = Zero() +Base.rem(x::Zero, ::Integer) = x Base.rem(@nospecialize(x::StaticNumber), T::Type{<:Integer}) = rem(known(x), T) Base.rem(::StaticNumber{X}, ::StaticNumber{Y}) where {X, Y} = static(rem(X, Y)) Base.rem(x::Real, ::StaticInteger{Y}) where {Y} = rem(x, Y) @@ -485,6 +488,8 @@ Base.:(>>>)(::StaticInteger{X}, ::StaticInteger{Y}) where {X, Y} = static(>>>(X, Base.:(>>>)(::StaticInteger{X}, n::Integer) where {X} = >>>(X, n) Base.:(>>>)(x::Integer, ::StaticInteger{N}) where {N} = >>>(x, N) +Base.:(&)(::Integer, y::Zero) = y +Base.:(&)(x::Zero, ::Integer) = x Base.:(&)(::StaticInteger{X}, ::StaticInteger{Y}) where {X, Y} = static(X & Y) Base.:(&)(::StaticInteger{X}, y::Union{Integer, Missing}) where {X} = X & y Base.:(&)(x::Union{Integer, Missing}, ::StaticInteger{Y}) where {Y} = x & Y diff --git a/test/runtests.jl b/test/runtests.jl index 7f38706..7e0664e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -111,6 +111,13 @@ end @test mod(static(3), static(2)) === static(1) @test mod(static(3), 2) == 1 @test mod(3, static(2)) == 1 + + @test rem(3, static(1)) == static(0) + @test rem(3, static(-1)) == static(0) + @test rem(static(0), 3) == static(0) + + @test static(0) & 3 == static(0) + @test 3 & static(0) == static(0) end @testset "StaticBool" begin