Skip to content

Commit c6d7229

Browse files
authored
Merge pull request #32 from pietroppeter/improve-documentation
Improve documentation
2 parents 78edddf + a4e431b commit c6d7229

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

TODO

Lines changed: 0 additions & 8 deletions
This file was deleted.

readme.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,42 @@
22

33
![test](https://github.com/def-/nim-bigints/workflows/test/badge.svg)
44

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+
541
The following api documentation is generated with [mddoc](https://github.com/treeform/mddoc). To regenerate install `mddoc` with nimble and run
642

743
```

0 commit comments

Comments
 (0)