Hello. I'm new to Java and I keep having problems doing conversions.

I am trying to convert a BigInteger to an integer in order to use modPow(BigInteger exponent, BigInteger). I have enclosed my code below- any help or a recommended place to go would be appreciated.

public BigInteger modPow(BigInteger exponent, BigInteger m)

First thing to note is that modPow is not a static method. This means that you call it on a specific BigInteger (in this case g.) It takes two BigIntegers (in this case d and p.) You don't need to convert to an int. This is good as you raise to exponents that are larger than can fit in an int. Finally, it returns a BigInteger (which you are storing in y.)