Modulo with negative number
Modulo is not working with value1 as a negative number.
println(-1 % 10);
The result of this was -1.
The expected result was 9.
No, this is as expected.
% is performed by the underlying Java operator. In Java, % is calculated as the remainder, and "the result of the remainder operation can be negative only if the dividend is negative, and can be positive only if the dividend is positive."
See the language spec:
https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.17.3
If you want the other behavior, try using Math.floorMod(int x, int y)
https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#floorMod-int-int-
Further discussion though should be on the discourse.processing.org forums; issues is for bug reports only.
This issue has been automatically closed and locked.
Processing 3.x is no longer actively developed. Since January 2020, development moved to the Processing 4 repository.
If this issue is still relevant to Processing 4, we'd love to hear from you. Please open a new issue at: https://github.com/processing/processing4/issues/new/choose
Thank you for helping improve Processing.