Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions base/div.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ rem(x, y, r::RoundingMode)
rem(x, y, ::RoundingMode{:ToZero}) = rem(x, y)
rem(x, y, ::RoundingMode{:Down}) = mod(x, y)
rem(x, y, ::RoundingMode{:Up}) = mod(x, -y)
rem(x, y::Unsigned, ::RoundingMode{:Up}) =
throw(ArgumentError("rem(x, y, RoundUp) cannot be used with unsigned y")) # issue #34325
rem(x, y, r::RoundingMode{:Nearest}) = x - y * div(x, y, r)
rem(x::Integer, y::Integer, r::RoundingMode{:Nearest}) = divrem(x, y, r)[2]

Expand Down
7 changes: 7 additions & 0 deletions test/numbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1751,6 +1751,13 @@ end
@test rem(typemin(T), T(-1)) === T(0)
@test mod(typemin(T), T(-1)) === T(0)
end
@testset "issue #34325" for S in (Int8, Int16, Int32, Int64, Int128)
U = unsigned(S)
@test rem(S(10), S(7), RoundUp) == -4
@test rem(U(10), S(7), RoundUp) == -4
@test_throws ArgumentError rem(S(10), U(7), RoundUp)
@test_throws ArgumentError rem(U(10), U(7), RoundUp)
end
end
@testset "issue #4156" begin
@test fld(1.4, 0.35667494393873234) == 3.0
Expand Down
Loading