|
2 | 2 |
|
3 | 3 | 
|
4 | 4 |
|
| 5 | +This library provides a pure implementation for arbitrary precision integers in [Nim](https://nim-lang.org/). |
| 6 | + |
| 7 | +It can be installed through nimble with: |
| 8 | + |
| 9 | +``` |
| 10 | +nimble install bigints |
| 11 | +``` |
| 12 | + |
| 13 | +`bigints` provides a `BigInt` type and related operations with standard Nim syntax: |
| 14 | + |
| 15 | +- creation of `BigInt` from all standard integer types (`initBigInt`) |
| 16 | +- comparisons (`<`, `<=`, `==`) |
| 17 | +- addition, negation and subtraction (`+`, `-`, `+=` `-=`) |
| 18 | +- multiplication (`*`, `*=`) |
| 19 | +- bit shifts (`shr`, `shl`) |
| 20 | +- integer division and modulo operation (`div`, `mod`) |
| 21 | +- exponentiation (`^`, `pow`) |
| 22 | +- conversion of `BigInt` from/to strings supporting bases from 2 to 36 (`initBigInt`, `$`) |
| 23 | +- iteration utilities (`inc`, `dec`, `countdown`, `countup`, `..`, `..<`) |
| 24 | + |
| 25 | +Most of the operations above (all those for which it makes sense) are also available between a `BigInt` and a `int32`. |
| 26 | + |
| 27 | +For examples of usage see the [examples](examples) folder. |
| 28 | + |
| 29 | +## Current limitations and possible enhancements |
| 30 | + |
| 31 | +* cannot multiply a number with itself (x *= x). An issue like this exist also for addition (#27) and possibly other operations |
| 32 | +* an uninitialized `BigInt` might raise error when performing some operations (e.g. #26) |
| 33 | +* not expected to work on 32 bit |
| 34 | +* some common bitwise operations (`and`, `or`, `xor`, `not`) are not implemented |
| 35 | +* operations between `BigInt` and standard integer types besides `int32` are not implemented |
| 36 | +* api for `BigInt` type is probably unstable (currently it is a `tuple`, it might become an `object` or `ref object` in the future) |
| 37 | +* arithmetical operations such as addition, multiplication and division are not optimized for performance (e.g. [karatsuba multiplication](https://en.wikipedia.org/wiki/Karatsuba_algorithm) is not implemented) |
| 38 | + |
| 39 | +## Full API documentation |
| 40 | + |
5 | 41 | The following api documentation is generated with [mddoc](https://github.com/treeform/mddoc). To regenerate install `mddoc` with nimble and run
|
6 | 42 |
|
7 | 43 | ```
|
|
0 commit comments