a = b; // From int to BigInteger...
b = a; // ...and back, no casts required!
/*
a = b; // From int to BigInteger...
b = a; // ...and back, no casts required!
/*
// This won't compile because the number is too big to be an
// integer literal.
//BigInteger e(3141592653589793238462643383279);
// This won't compile because the number is too big to be an
// integer literal.
//BigInteger e(3141592653589793238462643383279);
// Instead you can convert the number from a string.
std::string s("3141592653589793238462643383279");
BigInteger f = easyStringToBI(s);
// Instead you can convert the number from a string.
std::string s("3141592653589793238462643383279");
BigInteger f = easyStringToBI(s);
// All five ``return-by-value'' arithmetic operators.
std::cout << (g + h) << '\n' << (g - h) << '\n' << (g * h)
<< '\n' << (g / h) << '\n' << (g % h) << std::endl;
// All five ``return-by-value'' arithmetic operators.
std::cout << (g + h) << '\n' << (g - h) << '\n' << (g * h)
<< '\n' << (g / h) << '\n' << (g % h) << std::endl;
BigUnsigned i(0xFF0000FF), j(0x0000FFFF);
// All five ``return-by-value'' bitwise operators.
std::cout.flags(std::ios::hex | std::ios::showbase);
std::cout << (i & j) << '\n' << (i | j) << '\n' << (i ^ j) << '\n'
<< (j << 21) << '\n' << (j >> 10) << '\n';
std::cout.flags(std::ios::dec);
BigUnsigned i(0xFF0000FF), j(0x0000FFFF);
// All five ``return-by-value'' bitwise operators.
std::cout.flags(std::ios::hex | std::ios::showbase);
std::cout << (i & j) << '\n' << (i | j) << '\n' << (i ^ j) << '\n'
<< (j << 21) << '\n' << (j >> 10) << '\n';
std::cout.flags(std::ios::dec);
// Let's do some heavy lifting and calculate powers of 314.
int maxPower = 10;
BigUnsigned x(1), big314(314);
// Let's do some heavy lifting and calculate powers of 314.
int maxPower = 10;
BigUnsigned x(1), big314(314);
std::cout << "314^" << power << " = " << x << std::endl;
x *= big314; // A BigInteger assignment operator
}
std::cout << "314^" << power << " = " << x << std::endl;
x *= big314; // A BigInteger assignment operator
}
/*
* If you want to experiment with the library,
* you can add your own test code here.
*/
// std::cout << "Beginning of custom test code:" << std::endl;
/*
* If you want to experiment with the library,
* you can add your own test code here.
*/
// std::cout << "Beginning of custom test code:" << std::endl;