Skip to content

Improve documentation #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions TODO

This file was deleted.

36 changes: 36 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,42 @@

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

This library provides a pure implementation for arbitrary precision integers in [Nim](https://nim-lang.org/).

It can be installed through nimble with:

```
nimble install bigints
```

`bigints` provides a `BigInt` type and related operations with standard Nim syntax:

- creation of `BigInt` from all standard integer types (`initBigInt`)
- comparisons (`<`, `<=`, `==`)
- addition, negation and subtraction (`+`, `-`, `+=` `-=`)
- multiplication (`*`, `*=`)
- bit shifts (`shr`, `shl`)
- integer division and modulo operation (`div`, `mod`)
- exponentiation (`^`, `pow`)
- conversion of `BigInt` from/to strings supporting bases from 2 to 36 (`initBigInt`, `$`)
- iteration utilities (`inc`, `dec`, `countdown`, `countup`, `..`, `..<`)

Most of the operations above (all those for which it makes sense) are also available between a `BigInt` and a `int32`.

For examples of usage see the [examples](examples) folder.

## Current limitations and possible enhancements

* cannot multiply a number with itself (x *= x). An issue like this exist also for addition (#27) and possibly other operations
* an uninitialized `BigInt` might raise error when performing some operations (e.g. #26)
* not expected to work on 32 bit
* some common bitwise operations (`and`, `or`, `xor`, `not`) are not implemented
* operations between `BigInt` and standard integer types besides `int32` are not implemented
* api for `BigInt` type is probably unstable (currently it is a `tuple`, it might become an `object` or `ref object` in the future)
* 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)

## Full API documentation

The following api documentation is generated with [mddoc](https://github.com/treeform/mddoc). To regenerate install `mddoc` with nimble and run

```
Expand Down