Skip to content

Commit 8eee8d5

Browse files
JeffBezansonKristofferC
authored andcommitted
restrict div fallback to Real (#34284)
add more-compatible fallback for `divrem` (cherry picked from commit 8f53987)
1 parent 3797ea9 commit 8eee8d5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

base/div.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,17 @@ julia> divrem(7,3)
116116
```
117117
"""
118118
divrem(x, y) = divrem(x, y, RoundToZero)
119-
divrem(a, b, r::RoundingMode) = (div(a, b, r), rem(a, b, r))
119+
function divrem(a, b, r::RoundingMode)
120+
if r == RoundToZero
121+
# For compat. Remove in 2.0.
122+
(div(a, b), rem(a, b))
123+
elseif r === RoundDown
124+
# For compat. Remove in 2.0.
125+
(fld(a, b), mod(a, b))
126+
else
127+
(div(a, b, r), rem(a, b, r))
128+
end
129+
end
120130
function divrem(x::Integer, y::Integer, rnd::typeof(RoundNearest))
121131
(q, r) = divrem(x, y)
122132
if x >= 0

0 commit comments

Comments
 (0)