1

I am supposed to build a program for storing and handling huge integers. I know that there are many answers out there but I need ideas that I can implement easily, bearing in mind that I can use any of the basic concepts of C/C++.

How should I go about it?

This is the first time I am asking a question here so please correct me if I am wrong about anything.

Edit: Actually what I wanted to know was how should I go about storing a huge integer... Obviously an array is what comes to mind at first glance but are there any other methods out there at the basic level?

EDIT2: I came across a very nice solution to this problem a while ago, but was just a bit lazy to put it on here. We can use the concept of number systems to deal with huge numbers. We can declare an array that holds the co-efficient of powers of 256, thus obtaining a base 256 system. We can then use fundamental concepts like those of the various number systems to obtain our required results.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
iluvthee07
  • 491
  • 1
  • 5
  • 16

2 Answers2

1

Matt McCutchen has a Big Integer Library

If you want to do this yourself his code would be a great starting point. As you can overload arithmetic operators in C++ it is not too difficult to make a new BigInteger class and make this handle any number of bits per integer.

There is also a stack overflow answer to this question: here

Community
  • 1
  • 1
David Elliman
  • 1,379
  • 8
  • 15
0

I consider this as a question about theory, as such I suggest to browse the internet using the right keywords for documents/articles or to take a sneak peek at libraries that are implementing this feature and are well tested, this projects also tend to offer a mailing list or a forum where developers can communicate, it can be a good place to start writing about this stuff.

user2485710
  • 9,451
  • 13
  • 58
  • 102