Displaying Long integers

Hi,

Could someone please tell me how I can display realllly long integers? I am doing one of the project euler questions, and one part of it requires finding out the answer to 2^1000. My code works up to a certain point (2^62), but is unable to show anything larger.

If possible, I would like to avoid additional libraries.


Thanks!

p.s Sorry if the answer is really simple- I'm still new to this :)


1
2
3
4
5
6
7
8
9
10
int main()
{
    long long a=2, b=a, c=1000, x=1;  // (a^c) in this case 2^1000
    while(x<c){
       b*=a;
       x++;
       }  
    cout<<b << endl;
    cin.get();
}
Do the problem in a different language than c/c++. Try java, ruby or python or you have to download a big integer library online somewhere.
one possible solution is instead of long long, try to implement multiplication using strings. You shall have to construct your own function in which you take two strings as input and return their product again as a string.
Topic archived. No new replies allowed.