Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/say4n/infinity
signed arbitrary precision arithmetic library
https://github.com/say4n/infinity
arbitrary-precision-integers cpp11 mathematics
Last synced: about 1 month ago
JSON representation
signed arbitrary precision arithmetic library
- Host: GitHub
- URL: https://github.com/say4n/infinity
- Owner: say4n
- License: gpl-3.0
- Created: 2018-12-08T06:53:23.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-05T19:27:10.000Z (about 6 years ago)
- Last Synced: 2024-11-08T03:02:53.628Z (3 months ago)
- Topics: arbitrary-precision-integers, cpp11, mathematics
- Language: C++
- Homepage:
- Size: 175 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
a signed arbitrary precision arithmetic library
**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!
## contents
1. [usage](#usage)
2. [tests](#tests)
3. [example](#example)
- [integer](#integer)
- [float](#float)
4. [warning](#warning)
5. [author](#author)## usage
1. Build `libInfinity.a` using `make all` in the `src` directory.
2. Copy the header files and `libInteger.a` file to your project.
3. Include the header files as per requirement in your source file.
4. Compile with `-L$(LIB)` and `-lInfinity` flags where `LIB` is the directory where `libInfinity.a` resides in.## tests
Run `make testInteger` in the `src` directory to compile the sanity checks. Execute the generated executable with `./test.out`.
## example
### integer
```cpp
#include
#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:
```bash
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)
```### float
work in progress
## warning
This a pet project to explore arbitrary precision arithmetic. If you need arbitrary precision arithmetic, consider using something more mature like [GMP](https://gmplib.org).## author
Sayan Goswami (c) 2018