Skip to content

Commit

Permalink
Whitespace/test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno committed Aug 25, 2019
1 parent 302184e commit a71f150
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
22 changes: 11 additions & 11 deletions base/div.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,47 +117,47 @@ function divrem(x::Integer, y::Integer, rnd::typeof(RoundNearest))
(q, r) = divrem(x, y)
if x >= 0
if y >= 0
r >= (y÷2) + (isodd(y) | iseven(q)) ? (q+true, r-y) : (q, r)
r >= (y÷2) + (isodd(y) | iseven(q)) ? (q+true, r-y) : (q, r)
else
r >= -(y÷2) + (isodd(y) | iseven(q)) ? (q-true, r+y) : (q, r)
r >= -(y÷2) + (isodd(y) | iseven(q)) ? (q-true, r+y) : (q, r)
end
else
if y >= 0
r <= -signed(y÷2) - (isodd(y)| iseven(q)) ? (q-true, r+y) : (q, r)
r <= -signed(y÷2) - (isodd(y) | iseven(q)) ? (q-true, r+y) : (q, r)
else
r <= (y÷2) - (isodd(y) | iseven(q)) ? (q+true, r-y) : (q, r)
r <= (y÷2) - (isodd(y) | iseven(q)) ? (q+true, r-y) : (q, r)
end
end
end
function divrem(x::Integer, y::Integer, rnd:: typeof(RoundNearestTiesAway))
(q, r) = divrem(x, y)
if x >= 0
if y >= 0
r >= (y÷2) + isodd(y) ? (q+true, r-y) : (q, r)
r >= (y÷2) + isodd(y) ? (q+true, r-y) : (q, r)
else
r >= -(y÷2) + isodd(y) ? (q-true, r+y) : (q, r)
r >= -(y÷2) + isodd(y) ? (q-true, r+y) : (q, r)
end
else
if y >= 0
r <= -signed(y÷2) - isodd(y) ? (q-true, r+y) : (q, r)
else
r <= (y÷2) - isodd(y) ? (q+true, r-y) : (q, r)
r <= (y÷2) - isodd(y) ? (q+true, r-y) : (q, r)
end
end
end
function divrem(x::Integer, y::Integer, rnd::typeof(RoundNearestTiesUp))
(q, r) = divrem(x, y)
if x >= 0
if y >= 0
r >= (y÷2) + isodd(y) ? (q+true, r-y) : (q, r)
r >= (y÷2) + isodd(y) ? (q+true, r-y) : (q, r)
else
r >= -(y÷2) + true ? (q-true, r+y) : (q, r)
r >= -(y÷2) + true ? (q-true, r+y) : (q, r)
end
else
if y >= 0
r <= -signed(y÷2) - true ? (q-true, r+y) : (q, r)
r <= -signed(y÷2) - true ? (q-true, r+y) : (q, r)
else
r <= (y÷2) - isodd(y) ? (q+true, r-y) : (q, r)
r <= (y÷2) - isodd(y) ? (q+true, r-y) : (q, r)
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion test/int.jl
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ end
end

@test div(typemax(Int64), typemax(Int64)-1, RoundNearest) == 1
@test div(-typemax(Int64), typemax(Int64)-1, RoundNearest) == -2
@test div(-typemax(Int64), typemax(Int64)-1, RoundNearest) == -1
@test div(typemax(Int64), 2, RoundNearest) == 4611686018427387904
@test div(-typemax(Int64), 2, RoundNearestTiesUp) == -4611686018427387903
@test div(typemax(Int)-2, typemax(Int), RoundNearest) == 1
end

0 comments on commit a71f150

Please sign in to comment.