C++ Big Integer

There are a bunch of suggestions here for existing implementations: C++ handling very large integers

If you have to implement your own (e.g. for homework), then you have to decide the best way, and how “big” you need to handle. You could use an array of DWORDs, and handle overflowing from one to the next.

Although, for some of the Project Euler stuff, I actually implemented a BigNumber class built on a string. It turned out to be the simplest to implement for +-*/, and scaled to significantly longer numbers than I could get with a few unsigned long longs. And the performance was perfectly adequate for solving those puzzles.

So, you face a tradeoff between ease of implementation and optimal performance. Have fun šŸ˜‰

Leave a Comment