-1

I am looking to use very big numbers (up to 255 figures in one variable) and manipulating these values on basic level (+, -, *, /, ^ and √) in C++ but I am not sure whether using bigInt (https://mattmccutchen.net/bigint/) will handle such big numbers.

Kanwaljit Singh
  • 4,339
  • 2
  • 18
  • 21
  • https://www.google.com/#q=arbitrary+precision+library+c%2B%2B – user2485710 Dec 28 '13 at 10:07
  • 3
    Citing the linked page: _"You can use this library in a C++ program to do arithmetic on integers of size limited only by your computer's memory"_. I bet that your computer has enough memory to handle 255 figures, and even more! But note that this library is only for _integer_, not fractions or decimals, hence the name, – rodrigo Dec 28 '13 at 10:08

2 Answers2

2

Similar to here, I will recommend you to check out The Large Integer Case Study in C++.pdf by Owen Astrachan. I found this file extremely useful with detail introduction and code implementation. It doesn't use any 3rd-party library. I have used this to handle huge numbers (as long as you have enough memory to store vector<char>) with no problems.


Idea: It implements an arbitrary precision integer class by storing big int in a vector<char>.

vector<char> myDigits; // stores all digits of number

Then all operations related to the big int, including <<, >>, +, -, *, ==, <, !=, >, etc., can be done based on operations on this char array.


Edit: Btw, bigInt is fine too.

Community
  • 1
  • 1
herohuyongtao
  • 49,413
  • 29
  • 133
  • 174
1

i'll suggest you to use GMP (https://gmplib.org). it's work with arbitrary length numbers.

zapredelom
  • 1,009
  • 1
  • 11
  • 28