]> git.lizzy.rs Git - rust.git/blob - src/docs/modulo_arithmetic.txt
[Arithmetic] Consider literals
[rust.git] / src / docs / modulo_arithmetic.txt
1 ### What it does
2 Checks for modulo arithmetic.
3
4 ### Why is this bad?
5 The results of modulo (%) operation might differ
6 depending on the language, when negative numbers are involved.
7 If you interop with different languages it might be beneficial
8 to double check all places that use modulo arithmetic.
9
10 For example, in Rust `17 % -3 = 2`, but in Python `17 % -3 = -1`.
11
12 ### Example
13 ```
14 let x = -17 % 3;
15 ```