infinity, as of present, is by no means a replacement for any serious work, it is a weekend hack at best. Please proceed with extreme caution. You have been warned!
- Build
libInfinity.a
usingmake all
in thesrc
directory. - Copy the header files and
libInteger.a
file to your project. - Include the header files as per requirement in your source file.
- Compile with
-L$(LIB)
and-lInfinity
flags whereLIB
is the directory wherelibInfinity.a
resides in.
Run make testInteger
in the src
directory to compile the sanity checks. Execute the generated executable with ./test.out
.
#include <iostream>
#include "Integer.h"
int main() {
Integer a("80");
Integer b("4");
Integer c = 11;
Integer d = 100;
std::cout << "a :: " << a;
std::cout << "b :: " << b;
std::cout << "c :: " << c;
std::cout << "d :: " << d;
std::cout << "a <= b :: " << (a <= b) << std::endl;
std::cout << "a < b :: " << (a < b) << std::endl;
std::cout << "a >= b :: " << (a >= b) << std::endl;
std::cout << "a > b :: " << (a > b) << std::endl;
std::cout << "a == b :: " << (a == b) << std::endl;
std::cout << "a != b :: " << (a != b) << std::endl;
std::cout << "-a :: " << -a;
std::cout << "a + b :: " << a + b;
std::cout << "a - b :: " << a - b;
std::cout << "a * b :: " << a * b;
std::cout << "a / b :: " << a / b;
std::cout << "a % b :: " << a % b;
std::cout << "Integer::pow(c, d) :: " << Integer::pow(c, d);
return 0;
}
Which results in:
a :: Integer(+80)
b :: Integer(+4)
c :: Integer(+11)
d :: Integer(+100)
a <= b :: 0
a < b :: 0
a >= b :: 1
a > b :: 1
a == b :: 0
a != b :: 1
-a :: Integer(-80)
a + b :: Integer(+84)
a - b :: Integer(+76)
a * b :: Integer(+320)
a / b :: Integer(+20)
a % b :: Integer(+0)
Integer::pow(c, d) :: Integer(+137806123398222701841183371720896367762643312000384664331464775521549852095523076769401159497458526446001)
work in progress
This a pet project to explore arbitrary precision arithmetic. If you need arbitrary precision arithmetic, consider using something more mature like GMP.
Sayan Goswami (c) 2018