Implementation of long arithmetic on C++.
BigIntegerLibrary::BigInteger a, b, c;
c = a + b;
c += a;
c = a + 6;
c += 6;
BigIntegerLibrary::BigInteger a, b, c;
c = a - b;
c -= a;
c = a - 6;
c -= 6;
BigIntegerLibrary::BigInteger a, b, c;
c = a * b;
c *= a;
c = a * 6;
c *= 6;
BigIntegerLibrary::BigInteger a, b, c;
c = a / b;
c /= a;
c = a / 6;
c /= 6;
c = a % b;
c %= a;
c = a % 6;
c %= 6;
BigIntegerLibrary::BigInteger a(152);
BigIntegerLibrary::BigInteger b(22943);
if (a == b) cout << "A is equal to B";
if (a < b) cout << "A is less than B";
if (a > b) cout << "A is greater than B";
if (a >= b) cout << "A is greater than or equal to B";
if (a <= b) cout << "A is less than or equal to B";
if (a != b) cout << "A is not equal to B";
BigIntegerLibrary::BigInteger a, b;
cin >> a >> b;
cout << a * b;
Converts the big integer to a string.
BigIntegerLibrary::BigInteger a(-152);
string str = a.to_string();
Absolute value.
BigIntegerLibrary::BigInteger a(-152);
cout << BigIntegerLibrary::abs(a); // 152
Raises to the power of N.
BigIntegerLibrary::BigIntegert a = 19;
cout << BigIntegerLibrary::pow(a, 87); // ~1.784e+111
Return the int part of squared root.
BigIntegerLibrary::BigInteger a = 120;
cout << BigIntegerLibrary::sqrt(a); // [~10.954] = 10
Return greatest common divisor of abs(a) and abs(b).
BigIntegerLibrary::BigInteger a = -30;
BigIntegerLibrary::BigInteger b = 12;
cout << BigIntegerLibrary::gcd(a, b); // gcd(30, 12) = 6