Вопрос

int p=223;
int q=569;
int n=p*q;
double num=65;
double d=100877;
exp=Math.pow(num,d);
c=(exp)%n;
System.out.print(expo);
System.out.print("\n"+Math.pow(65, 100877));

OUTPUT: 2147483647 Infinity

but the actual result has more than 3000 digits, how can i get complete number?

Это было полезно?

Решение

BigInteger should help you to do that calculation. But I am afraid you can use Math.pow() , as it may not be able to generate the big number as you desire. Math.pow will be limited by the range of double as the method signature uses double for both input and returning the output. You may have to implement your own pow method which should return a BigInteger.

Edit: I just checked it and found that java.math.BigInteger.pow(int exponent) will be your friend.

Другие советы

Look at BigInteger. It will help.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top