Calculate pow(int n) with BigDecimal number in different method

I'm trying to use BigDecimal function pow(int n), and it works fine for me. However, when I enter large numbers it takes more time to calculate which is not good for my algorithm. Is there a faster way to calculate power of numbers and returns exactly, to unlimited precision? Below is an example of my case:

private static BigDecimal decryption(BigDecimal cipherTxt, int dVal){

return cipherTxt.pow(dVal);


When I enter:

cipherTxt = 11395128

dVal = 19299953


It takes more time, and it is not useful for my program....

Read More »

By: StackOverFlow - 6 days ago

Related Posts