|
-
August 26th, 2005, 04:58 AM
#1
Are there bigger integers than "long long"?
Hi folks,
I scribbled a little c++ program whilst in the bar ;-) last night. It was simply to calculate Fibonacci numbers (you know, the sum of the previous 2)
Basically I calculated up to about the 20th (using a simple int declaration) before the output started "acting up" basically the numbers got too big for a simple int.
I changed the declaration to "long long int" and this got me to the 92nd Fibonacci number before becoming again too large:
89. 2880067194370816120
90. 4660046610375530309
91. 7540113804746346429
92. -6246583658587674878 <----this one added a "-" sign.
Here's the code:
//CODE
#include <iostream>
int main()
{
long long int i1 = 0;
long long int i2 = 1;
long long int fib;
{
for (int x = 1; x <= 92; ++x){
fib = i1 + i2;
std::cout << x;
std::cout << ".";
std::cout << " ";
std::cout << fib << endl;
i1 = i2;
i2 = fib;
}
}
return 0;
}
//CODE
Can I go any higher in calculating these numbers?
Thanks.
Sundodger.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|