- Addition
- Subtraction
- Unary minus
- Multiplication
- Division
- Modulo
- Allocation
- Comparison
- Access
- Stream operators
To build this project you need: CMake, make, gcc/clang. Also build.sh requires you to have installed and in path: clang-format, clang-tidy
For testing you need additionally lcov with it's tools: geninfo and gcov.
Bigint class provides math operations for arbitrarily large numbers.
Bigint a, b, c;
c = a + b;
c += a;
c = a + 6;
c += 6;
Bigint a, b, c;
c = a - b;
c -= a;
cout << -Bigint(10) // -10
Bigint a, b, c;
c = a * b;
c *= a
c = a * 6;
c *= 6;
Bigint a, b;
Bigint c;
c = a / b;
Bigint a;
int b;
b = a % 31415;
Bigint a = 159753;
Bigint b = 1634687496;
if(a == b) cout << "A is the same as B";
if(a < b) cout << "A is less than B";
if(a > b) cout << "A is larger than B";
if(a >= b) cout << "A is larger than B or equal to it";
if(a <= b) cout << "A is smaller than B or equal to it";
Bigint a = 12345;
Bigint b;
b = 159753;
Bigint c = "12345";
Bigint d = b;
Bigint e;
e = "23498523524";
Bigint a = 159753;
a.pow(15); //a^15, 1126510743106482...
cout << a[3]; // 6 is the 4th digit from the left
Bigint b = 123456789;
cout << b(2); // 7 is the 3th digit from the right
Bigint a, b;
cin >> a >> b;
cout << a * b;
Clears the Bigint, making it equal to 0.
Bigint a = 4558;
cout << a.pow(486); // ~1.46 * 10^1778
a.clear();
cout << a; // 0
Absolute value.
Bigint a = -4558;
cout << a.abs() // 4558
Raises to the power of N.
Bigint a = 4558;
cout << a.pow(486); // ~1.46 * 10^1778
Returns the number of digits.
Bigint a = 4558;
cout << a.pow(486).digits(); // 4558^486 = 1779 digit number
Returns true is the number is even.
Bigint a = 4558;
cout << a.isEven(); // true
Returns true is the number is negative.
Bigint a = -4558;
cout << a.isNegative(); // true
Converts the big integer to a string.
string str;
Bigint a = 455897864531248;
str = a.toString();
Clones Bigint with the same value
Bigint a = 455897864531248;
Bigint b = a.clone();
cout << a == b // true
Multiplies number by pow(10, n) - faster than a*10^n
Bigint a = 455897864531248;
a.addZeroes(4);
cout << a // 4558978645312480000
cout << a.addZeroes(3) // 4558978645312480000000
Divides number by pow(10, n) - faster than a/10^n
Bigint a = 3433123100000;
a.remove_trailing(4);
cout << a // 34331231
Bigint b = "3433123156364113314123"
cout << a.remove_trailing(11) // 34331231563
Converts the big integer to a string.
string str;
Bigint a = 455897864531248;
str = toString(a);