Multiple Precision Integer Arithmetic C++ Library.
Feature |
Implementation |
Next Candidate |
Constructors |
std::string, int, long int, long long int, intf |
|
Containers |
std::vector<> |
std::vector<std::bitset<> > |
+ |
standard |
|
- |
standard |
|
* |
Long multiplication |
Karatsuba multiplication, Toom–Cook, Schönhage–Strassen, Fürer's algorithm, Harvey and van der Hoeven |
/ |
Approximate Division |
Newton–Raphson, Goldschmidt, Binomial Goldschmidt, Barrett reduction, Montgomery reduction |
% |
Approximate Division |
Newton–Raphson, Goldschmidt, Binomial Goldschmidt, Barrett reduction, Montgomery reduction |
pow |
standard |
Exponentiation by squaring |
sqrt |
bisection |
Babylonian(Heron), Newton-Raphson, Goldschmidt, Bakhshali approximation, Fast inverse square root |
modexp |
|
Right-to-left binary |
modinv |
|
|
abs |
|
|
>> |
repetitive approximate division |
|
<< |
repetitive approximate division |
|
& |
|
|
^ |
|
|
xor |
|
|
ostream>> |
|
|
ostream<< |
|
|
gcd |
|
|
gcdeuc |
|
|
lcm |
|
|
Step |
Progress |
Code Refactoring |
|
Templating |
|
Next Feature Candidates |
|
Implementing Missing Features |
|
- lib:
- GCC compiler with C++11 support.
- CMake 3.10.2
- tests:
git clone https://github.com/AlyShmahell/intf
#include <intf/intf.hpp>
int main()
{
intf a = 4;
intf b = 3;
intf c;
std::cout<<(a/b)<<std::endl;
std::cout<<(a%b)<<std::endl;
std::cout<<(a*b)<<std::endl;
std::cout<<(a-b)<<std::endl;
std::cout<<(a+b)<<std::endl;
std::cout<<pow(a,3)/pow(b,3)<<std::endl;
std::cout<<pow(a,3)%pow(b,3)<<std::endl;
std::cout<<pow(a,2)*pow(b,2)<<std::endl;
std::cout<<pow(a,3)-pow(b,3)<<std::endl;
std::cout<<pow(a,3)+pow(b,3)<<std::endl;
std::cout<<(a--)<<std::endl;
std::cout<<(--a)<<std::endl;
std::cout<<(a++)<<std::endl;
std::cout<<(++a)<<std::endl;
std::cout<<(a<<3)<<std::endl;
std::cout<<(a>>4)<<std::endl;
std::cout<<(a*a)<<std::endl;
std::cout<<(a-a)<<std::endl;
std::cout<<(a+a)<<std::endl;
c = sqrt(a);
std::cout<<pow(c,2)<<std::endl;
a = a*(a+2);
a >>= 1;
std::cout<<a<<std::endl;
a >>= intf(2);
std::cout<<a<<std::endl;
a <<= 3;
std::cout<<a<<std::endl;
a <<= intf(4);
std::cout<<a<<std::endl;
a += 3;
std::cout<<a<<std::endl;
a += b;
std::cout<<a<<std::endl;
a -= 3;
std::cout<<a<<std::endl;
a -= b;
std::cout<<a<<std::endl;
a *= 3;
std::cout<<a<<std::endl;
a *= b;
std::cout<<a<<std::endl;
a /= 3+1;
std::cout<<a<<std::endl;
a /= b+1;
std::cout<<a<<std::endl;
a %= 3+1;
std::cout<<a<<std::endl;
a %= b+1;
std::cout<<a<<std::endl;
return 0;
}