Definition cdivz (x y : int) : int :=
(let q := (x %/ y) in
if (y == 0) || (2%:R * (x %% y)%Z <= `|y|) then
q else q + (-1) ^+ (y < 0)%R)%Z.
Infix "%c/" := cdivz (at level 40) : int_scope.

Lemma cdivz0 x : (x %c/ 0)%Z = 0.
Definition cmodz (x y : int) : int := x - (x %c/ y)%Z * y.