How to store very very large value in C/C++
I was writing a code to find out the number 2^1000.
Which is very very large, and no data type can handle this..
Actually I have to use the answer I get, and print the sum of it's digits.
So, the question is how can I really save this number, or there's another way without saving this.?
PS:- The code I have written is this..
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
long unsigned int res; //ignore the data types as of for now..
int i,sum;
sum=0;
res=pow(2,1000);
cout<<res<<endl;
while(res>0) //I know this loop will work, but just need to store that big value in
{ // variable res first..
i=res%10;
res/=10;
sum+=i;
}
cout<<sum;
getch();
}If I go for a double data type, then the loop would not work, because of the floating point values..Therefore, I need a way to do this...
Thanks..