views:

736

answers:

3
+2  Q: 

"BigInt" in C?

What is the easiest way to handle huge numbers in C? I need to store values in the Area 1000^900...

Does anybody know of an easy way to do that? Any help would really be appreciated!

+12  A: 

Use libgmp http://gmplib.org/

kmkaplan
+1 since libgmp is released under LGPL (not GPL which FSF is advocating: http://www.gnu.org/licenses/why-not-lgpl.html )
Jason S
+2  A: 

There are a few libraries to help you do this (arbitrary precision mathematics):

Assuming this isn't work related (ie you're doing it for fun or its a hobby or just an oportunity to learn something), coding up a library for arbitrary precision maths is a relatively interesting project. But if you need to absolutely rely on it and aren't interested in the nuts and bolts just use a library.

cletus
+1  A: 

There are a number of libraries for handling huge numbers around. Do you need integer or floating point arithmetic?

You could look at the code built into Python for the task.

You could look at the extensions for Perl for the task.

You could look at the code in OpenSSL for the task.

You could look at the GNU MP (multi-precision) library - as mentioned by kmkaplan.

Jonathan Leffler