diff options
Diffstat (limited to 'src/iter/utils.rs')
-rw-r--r-- | src/iter/utils.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/iter/utils.rs b/src/iter/utils.rs new file mode 100644 index 0000000..c168c92 --- /dev/null +++ b/src/iter/utils.rs @@ -0,0 +1,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 +}
\ No newline at end of file |