From 0c89e23a9233f582adb277257a90e2dfaf6ba7db Mon Sep 17 00:00:00 2001 From: MilkshakeForReal Date: Fri, 12 May 2023 10:39:06 -0600 Subject: [PATCH 1/6] Update Static.jl --- src/Static.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Static.jl b/src/Static.jl index 00e4bcf..6ecda1d 100644 --- a/src/Static.jl +++ b/src/Static.jl @@ -429,6 +429,7 @@ end Base.:(*)(::Union{AbstractFloat, AbstractIrrational, Integer, Rational}, y::Zero) = y Base.:(*)(x::Zero, ::Union{AbstractFloat, AbstractIrrational, Integer, Rational}) = x Base.:(*)(::StaticInteger{X}, ::StaticInteger{Y}) where {X, Y} = static(X * Y) +Base.:(/)(x::Zero, ::Union{AbstractFloat, AbstractIrrational, Integer, Rational}) = x Base.:(/)(::StaticInteger{X}, ::StaticInteger{Y}) where {X, Y} = static(X / Y) Base.:(-)(::StaticInteger{X}, ::StaticInteger{Y}) where {X, Y} = static(X - Y) Base.:(+)(::StaticInteger{X}, ::StaticInteger{Y}) where {X, Y} = static(X + Y) @@ -447,6 +448,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(::Union{AbstractFloat, AbstractIrrational, Integer, Rational}, y::One) = Zero() +Base.rem(::Union{AbstractFloat, AbstractIrrational, Integer, Rational}, y::StaticInt{-1}) = Zero() +Base.rem(x::Zero, ::Union{AbstractFloat, AbstractIrrational, Integer, Rational}) = 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 +489,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.:(&)(::Union{AbstractFloat, AbstractIrrational, Integer, Rational}, y::Zero) = y +Base.:(&)(x::Zero, ::Union{AbstractFloat, AbstractIrrational, Integer, Rational}) = 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 From 0e410498577f8084bed6e4123adbcdd605d5c357 Mon Sep 17 00:00:00 2001 From: MilkshakeForReal Date: Fri, 12 May 2023 10:42:44 -0600 Subject: [PATCH 2/6] Update Static.jl --- src/Static.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Static.jl b/src/Static.jl index 6ecda1d..dbe20db 100644 --- a/src/Static.jl +++ b/src/Static.jl @@ -448,9 +448,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(::Union{AbstractFloat, AbstractIrrational, Integer, Rational}, y::One) = Zero() -Base.rem(::Union{AbstractFloat, AbstractIrrational, Integer, Rational}, y::StaticInt{-1}) = Zero() -Base.rem(x::Zero, ::Union{AbstractFloat, AbstractIrrational, Integer, Rational}) = x +Base.rem(::Union{Integer}, y::One) = Zero() +Base.rem(::Union{Integer}, y::StaticInt{-1}) = Zero() +Base.rem(x::Zero, ::Union{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) From 5f398ae1d3872155e19b1a30017651145d8d0297 Mon Sep 17 00:00:00 2001 From: MilkshakeForReal Date: Fri, 12 May 2023 10:43:35 -0600 Subject: [PATCH 3/6] Update Static.jl --- src/Static.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Static.jl b/src/Static.jl index dbe20db..149e671 100644 --- a/src/Static.jl +++ b/src/Static.jl @@ -448,9 +448,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(::Union{Integer}, y::One) = Zero() -Base.rem(::Union{Integer}, y::StaticInt{-1}) = Zero() -Base.rem(x::Zero, ::Union{Integer}) = 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) From 3fb49b9216f5803dc21525f2886dce5eda2484e4 Mon Sep 17 00:00:00 2001 From: MilkshakeForReal Date: Fri, 12 May 2023 10:46:56 -0600 Subject: [PATCH 4/6] Update Static.jl --- src/Static.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Static.jl b/src/Static.jl index 149e671..30c8e67 100644 --- a/src/Static.jl +++ b/src/Static.jl @@ -489,8 +489,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.:(&)(::Union{AbstractFloat, AbstractIrrational, Integer, Rational}, y::Zero) = y -Base.:(&)(x::Zero, ::Union{AbstractFloat, AbstractIrrational, Integer, Rational}) = x +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 From 430d95d0cd4135f94dadbcf8c785a7bfdf4e6bdb Mon Sep 17 00:00:00 2001 From: MilkshakeForReal Date: Fri, 12 May 2023 14:16:42 -0600 Subject: [PATCH 5/6] test --- test/runtests.jl | 7 +++++++ 1 file changed, 7 insertions(+) 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 From 754e9f6df88ca816691c597f4f494ae5369417df Mon Sep 17 00:00:00 2001 From: MilkshakeForReal Date: Fri, 12 May 2023 14:19:01 -0600 Subject: [PATCH 6/6] Update Static.jl --- src/Static.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Static.jl b/src/Static.jl index 30c8e67..6db19a2 100644 --- a/src/Static.jl +++ b/src/Static.jl @@ -429,7 +429,6 @@ end Base.:(*)(::Union{AbstractFloat, AbstractIrrational, Integer, Rational}, y::Zero) = y Base.:(*)(x::Zero, ::Union{AbstractFloat, AbstractIrrational, Integer, Rational}) = x Base.:(*)(::StaticInteger{X}, ::StaticInteger{Y}) where {X, Y} = static(X * Y) -Base.:(/)(x::Zero, ::Union{AbstractFloat, AbstractIrrational, Integer, Rational}) = x Base.:(/)(::StaticInteger{X}, ::StaticInteger{Y}) where {X, Y} = static(X / Y) Base.:(-)(::StaticInteger{X}, ::StaticInteger{Y}) where {X, Y} = static(X - Y) Base.:(+)(::StaticInteger{X}, ::StaticInteger{Y}) where {X, Y} = static(X + Y)