Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nim-lang/bigints
BigInts for Nim
https://github.com/nim-lang/bigints
Last synced: 3 months ago
JSON representation
BigInts for Nim
- Host: GitHub
- URL: https://github.com/nim-lang/bigints
- Owner: nim-lang
- License: mit
- Created: 2014-06-28T02:40:04.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-12-28T11:36:47.000Z (11 months ago)
- Last Synced: 2024-02-24T23:48:56.189Z (9 months ago)
- Language: Nim
- Homepage:
- Size: 315 KB
- Stars: 117
- Watchers: 12
- Forks: 32
- Open Issues: 27
-
Metadata Files:
- Readme: readme.md
- License: license.txt
Awesome Lists containing this project
- awesome-nim - bigints - Bigints for Nim. (Algorithms / Bigints)
README
# Pure BigInts for Nim
[![test](https://github.com/nim-lang/bigints/actions/workflows/test.yaml/badge.svg)](https://github.com/nim-lang/bigints/actions/workflows/test.yaml)
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 https://github.com/nim-lang/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`)
- bitwise `not`, `and`, `or` and `xor` (behave as if negative numbers were represented in 2's complement)
- integer division and modulo operation (`div`, `mod`)
- conversion of `BigInt` from/to strings supporting bases from 2 to 36 (`initBigInt`, `$`)
- iteration utilities (`inc`, `dec`, `countdown`, `countup`, `..`, `..<`)## Current limitations and possible enhancements
* not expected to work on 32 bit
* arithmetic 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)## Documentation
The documentation is available at https://nim-lang.github.io/bigints.