문제

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