BigInteger class is used for mathematical operation which involves very big integer calculations that are outside the limit of all available primitive data types.
🚧 Work in progress 🚧
-
Download the bigInt.cpp file to a location under your include path. Then
#include
it in your code:#include "BigInt.cpp" // the actual path may vary
-
Create objects of the
BigInt
class, and do what you got to do!bigInt big1 = 1234567890, big2; big2 = "9876543210123456789098765432101234567890"; std::cout << big1 * big2 * 123456 << "\n"; // Output: 1505331490682966620443288524512589666204282352096057600
-
The second operand can either be a
bigInt
, an integer (up tolong long
) or a string (std::string
or a string literal).big1 = 1234567890; big1 = "123456789012345678901234567890"; big1 = big2;
-
big1 = +big2; // doesn't return the absolute value big1 = -big2;
-
One of the operands has to be a
bigInt
and the other can be abigInt
, an integer (up tolong long
) or a string (std::string
or a string literal).big1 = big2 + 1234567890; big1 = big2 - "123456789012345678901234567890"; big1 = big2 * big3; big1 = 1234567890 / big2; big1 = "123456789012345678901234567890" % big2;
-
The second operand can either be a
bigInt
, an integer (up tolong long
) or a string (std::string
or a string literal).big1 += big2; big1 -= 1234567890; big1 *= "123456789012345678901234567890"; big1 /= big2; big1 %= 1234567890;
-
Increment and Decrement can be done as it is done with general integer types of variables.
big1 = ++big2; // pre-increment big1 = --big2; // pre-decrement big1 = big2++; // post-increment big1 = big2--; // post-decrement
-
One of the operands has to be a
bigInt
and the other can be abigInt
, an integer (up tolong long
) or a string (std::string
or a string literal).if (big1 < 1234567890 or big1 > "123456789012345678901234567890" or big1 <= big2 or 1234567890 >= big1 or "123456789012345678901234567890" == big1 or big1 != big3) { ... }
-
std::cout << big1 << ", " << big2 << "\n"; output_file << big1 << ", " << big2 << "\n"; std::cin >> big1 >> big2; input_file >> big1 >> big2;
This Big Int class was created by sujon hasan and farid islam