java modulus operation

最近编程计算函数的non-linearity, 发现在java中-1 % 2 = -1,但是按照定义-1%2=1

there are two possible choices for the remainder, one negative and the other positive, and there are also two possible choices for the quotient. Usually, in number theory, the positive remainder is always chosen, but programming languages choose depending on the language and the signs of a and n . (from wiki)

你可能感兴趣的:(java modulus operation)