java的BigInteger里面的mod和remainder区别

直接上图



mod是模运算,remainder是求余运算,如果是正整数,mod和remainder没区别。

模运算的结果始终是个正数。

比如   -14 ÷ 3 = -4 ··· -2(余数符号和被除数相同)

这里如果是remainder,那么余数就是-2

如果是mod模运算,那么只要是非正数,就加上除数,这里加上3,mod模运算结果就是1

-10 ÷ 3 = -3 ··· -1

这里如果是remainder,那么余数就是-1

如果是mod模运算,那么只要是非正数,就加上除数,这里加上3,mod模运算结果就是2

========================================Talk is cheap, show me the code=======================================
CSDN博客地址:https://blog.csdn.net/qq_34115899
原文地址:https://www.cnblogs.com/lcy0515/p/9179791.html