tags:

views:

169

answers:

5

Possible Duplicate:
“BigInt” in C?

Hey there! I'm calculating the Fibonacci numbers in C up to 46 using an unsigned int, but I can't calculate F(47) because it's long. So, is there a way to get numbers bigger than 2^32 in C?
NB: I use a 32-bit processor.

+9  A: 

(unsigned) long long, but it's also limited (to 2^64). If it's not enough, you need to look for a BigInt library.

GameZelda
A: 

You should implement your own data type that is able to hold big numbers or use a library such as this one.

Hamid Nazari
+2  A: 
#include <stdint.h>

uint64_t my64bit;
Dacav
+1  A: 

You could try using 64-bit unsigned integers (check your C implementation for support), or simply use a BigNum package like GMP.

In the past, I've made BigNum libraries myself for various purposes but GMP blows my meagre efforts out of the water.

paxdiablo
A: 

I love the answer given by user R.. for this question here to operate on bigints. Of-course you have to implement your own add function if you want to scale it to very large numbers. It explains the steps very clearly.

Praveen S