1

我正在研究 powermod 功能并得到一些奇怪的结果,也许有人可以帮助解释我所看到的......

int a = 2147483647
int b = Integer.MAX_VALUE
int m = 3
long _A = (long) a;
BigInteger A = BigInteger.valueOf(a);
BigInteger M = BigInteger.valueOf(m);
// Compute with BigInteger  
int x = A.multiply(A).mod(M).intValue();
//compute with long
int y = (int) ((_A*_A) %m);
assert x ==y ; // is false?
4

0 回答 0