An Implementation of BigNumber library in C++
Develop with Xcode
#include "BigNumber.hpp"
BigNumber a {};
BigNumber a {"12345"};
BigNumber a {"-12345"};
BigNumber a {"-12345"};
bool b = a.getSign(); // true
string s = a.getNumber(); // "12345"
string ss = a.getString(); // "-12345"
string sss = string(a); // "-12345"
BigNumber b {};
b.setSign("false");
b.setNumber("999");
string(b); // "999"
BigNumber a {"11111"};
BigNumber b = a;
string(b); // "11111"
BigNumber a {"11111"};
BigNumber b {"22222"};
BigNumber c = a + b // "33333"
BigNumber d = {"-33333"}
BigNumber e = c + d; // "0"
BigNumber k += e;
BigNumber a {"22222"};
BigNumber b {"11111"};
BigNumber c = a - b; // "11111"
a -= b; // "11111"
BigNumber a {"100"};
BigNumber b {"100"};
BigNumber c = a * b; // "10000"
a *= b; // "10000"
CAN DIV NUMBER LARGE THAN "long long int"
BigNumber a {"1000"};
BigNumber b {"100"};
BigNumber c = a / b; // "10"
a /= b; // "10"
CAN MOD NUMBER LARGE THAN "long long int"
BigNumber a {"12"};
BigNumber b {"5"};
BigNumber c = a % b; // "2"
a %= b; // "2"
BigNumber d = {"-33333"};
d.absolute();
string(d); // 33333
BigNumber e = {"-100"};
BigNumber k = e.getAbsolute();
string(k); // "100"
string(e); // "-100"
BigNumber a {"11111"};
BigNumber b {"22222"};
if(a == b) // false
if(a != b) // true
if(a < b) // true
if(a <= b) // true
if(a > b) // false
if(a >= b) // false
- More operator
- Error Handler
Use Catch
http://hiltmon.com/blog/2014/10/26/simple-c-plus-plus-testing-with-catch-in-xcode/
https://github.com/philsquared/Catch
https://github.com/panks/BigInteger