The modulus remainder operator in Java is defined in the Java Language Specification, Second Edition, Section 15.17.3, paragraph 3:
...
Although clearly defined in the Java specification, the behavior is undefined in several early C implementations and a more general algebraic solution assumes a positive resultit is represented by the same symbol as the modulus operator, which always returns a positive value. Therefore, it is possible to have unintended behavior from use of this operator.
The result of the modulus remainder operator implies the following behavior:
...