https://github.com/hanabi1224/vlang-big-integer
Big interger implemented in pure vlang
https://github.com/hanabi1224/vlang-big-integer
Last synced: 3 months ago
JSON representation
Big interger implemented in pure vlang
- Host: GitHub
- URL: https://github.com/hanabi1224/vlang-big-integer
- Owner: hanabi1224
- License: mit
- Created: 2021-02-05T01:06:51.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-11-26T01:03:15.000Z (almost 2 years ago)
- Last Synced: 2025-03-30T19:13:40.097Z (6 months ago)
- Language: V
- Homepage:
- Size: 92.8 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vlang-big-integer
Big interger impelemented in pure vlang[](https://github.com/hanabi1224/vlang-big-integer/actions/workflows/main.yml)
[](https://ci.appveyor.com/project/hanabi1224/vlang-big-integer)
[](https://github.com/hanabi1224/vlang-big-integer/blob/master/LICENSE)## Install
```bash
v install hanabi1224.biginteger
```## Import
```v
import hanabi1224.biginteger
```## Usage
```v
v1 := biginteger.from_int(-3)
// Note that '_' and ',' are allowed, only base-10 is currently supported.
v2 := biginteger.from_str("-23333333333333333333333333333333333333")
v3 := biginteger.from_u64(9876554321)
// constants
zero := biginteger.zero
// + - * / %, TODO: pow etc.
println('$v2 + $ v3 = ${v2 + v3}')
println('$v2 - $ v3 = ${v2 - v3}')
println('$v2 * $ v3 = ${v2 * v3}')
println('$v2 / $ v3 = ${v2 / v3}')
println('$v2 % $ v3 = ${v2 % v3}')// bit shifting TODO: bit and / or ops
println('v2 << 32 = ${v2.lshift(32)}')
println('v2 >> 2 = ${v2.rshift(2)}')
```## Examples
### pidigits
```bash
v -prod -cc clang -gc boehm_full run ./examples/pidigits.v
```