Skip to content

Commit

Permalink
restrict div fallback to Real (#34284)
Browse files Browse the repository at this point in the history
add more-compatible fallback for `divrem`
  • Loading branch information
JeffBezanson authored Jan 7, 2020
1 parent c33298d commit 8f53987
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion base/div.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8f53987

Please sign in to comment.