blob: c168c920dfd09df2689155e98286375f6981e7ac (
plain)
1
2
3
4
5
6
7
8
|
pub fn pymod(a: isize, b: isize) -> isize {
let r = a % b;
// If r and b differ in sign, add b to wrap the result to the correct sign.
if (r > 0 && b < 0) || (r < 0 && b > 0) {
return r + b;
}
r
}
|