From 8f53987306e34d63da94dfaa66201aa009178e75 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 7 Jan 2020 15:52:35 -0500 Subject: [PATCH] restrict `div` fallback to `Real` (#34284) add more-compatible fallback for `divrem` --- base/div.jl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/base/div.jl b/base/div.jl index 5d91ba5ec19bb..ef85e2fe18b99 100644 --- a/base/div.jl +++ b/base/div.jl @@ -116,7 +116,17 @@ julia> divrem(7,3) ``` """ divrem(x, y) = divrem(x, y, RoundToZero) -divrem(a, b, r::RoundingMode) = (div(a, b, r), rem(a, b, r)) +function divrem(a, b, r::RoundingMode) + if r == RoundToZero + # For compat. Remove in 2.0. + (div(a, b), rem(a, b)) + elseif r === RoundDown + # For compat. Remove in 2.0. + (fld(a, b), mod(a, b)) + else + (div(a, b, r), rem(a, b, r)) + end +end function divrem(x::Integer, y::Integer, rnd::typeof(RoundNearest)) (q, r) = divrem(x, y) if x >= 0