How to handle arbitrarily large integers

Alex Gaynor picture Alex Gaynor · Nov 21, 2008 · Viewed 19.9k times · Source

I'm working on a programming language, and today I got the point where I could compile the factorial function(recursive), however due to the maximum size of an integer the largest I can get is factorial(12). What are some techniques for handling integers of an arbitrary maximum size. The language currently works by translating code to C++.

Answer

Barry Kelly picture Barry Kelly · Nov 21, 2008

If you need larger than 32-bits you could consider using 64-bit integers (long long), or use or write an arbitrary precision math library, e.g. GNU MP.