Question

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.

Was it helpful?

Solution

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

OTHER TIPS

#include <stdint.h>

uint64_t my64bit;

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.

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.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top