https://github.com/aveek-saha/intal
C library to perform calculations on integers of arbitrary length
https://github.com/aveek-saha/intal
arithmetic-computation c c-library karatsuba large-integers
Last synced: 9 months ago
JSON representation
C library to perform calculations on integers of arbitrary length
- Host: GitHub
- URL: https://github.com/aveek-saha/intal
- Owner: Aveek-Saha
- License: mit
- Created: 2019-11-07T16:54:58.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-08T16:18:11.000Z (over 6 years ago)
- Last Synced: 2025-09-09T13:03:47.039Z (9 months ago)
- Topics: arithmetic-computation, c, c-library, karatsuba, large-integers
- Language: C
- Size: 14.6 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Integers of Arbitrary Length
Intal is short for **Int**egers of **A**rbitrary **L**ength.
An intal (an integer of arbitrary length) is an object pointed to by a `void*` pointer. An intal can be created by `intal_create()` by providing a char string of a nonnegative integer provided in decimal digits. Some intals are created out of some functionalities like `intal_add()`, which creates a new intal.
Responsibility of destroying the intals created lies with the client by calling `intal_destroy()`, which will free whatever memory allocated during the creation of intal.
There is no theoretical limit to the size of the integer, except for memory limitations of the process (Operating System).
The operations that can be done on intals are-
* Addition
* Subtraction
* Multiplication(Karatsuba)
* Division
* Exponent
* Comparison
* Increment and decrement by 1
## How to run
1. To run the sanity check
```
$ gcc -c intal_sanity_check.c
$ gcc -Wall intal.c intal_sanity_check.o -lm -lrt -o intal.out
$ ./intal.out
```
2. Run a client file
```
$ gcc -c client.c
$ gcc -Wall intal.c client.o -lm -lrt -o intal.out
$ ./intal.out
```
3. Test for memory leaks with valgrind
```
$ valgrind --tool=memcheck ./intal.out
```