Search code examples
c++integerbigintegermemory-limit

Integers of unlimited size?


In Python, I can write a program to calculate integers of unlimited size. Just the other day I did the one millionth fibonacci number, and it was so large It was unable to fit in the console. If this is possible to do in Python, which to my understanding was written in C, how could one do the same in C++? It has to be possible, otherwise I don't see how it could be done in Python. I also believe there is something similar in Java/C# called a Biginteger, but I couldn't find anything saying how it could be implemented in C++.


Solution

  • Anything is possible in C/C++. You could write you own class called bigInteger and use an array to represent the number, but the best way is to use an already written library for working with big numbers, because those are very well optimized and a huge part of them is written in asm for extra speed. Here are a few examples: