public BigInteger modPow (BigInteger exponent, BigInteger m)

Returns a BigInteger whose value is (thisexponent mod m). (Unlike pow, this method permits negative exponents.)

Parameters:
exponent    the exponent.
m    the modulus.

Returns:  thisexponent mod m

Exceptions:
ArithmeticException    m ≤ 0 or the exponent is negative and this BigInteger is not relatively prime to m.

See also:
modInverse