https://github.com/plow-technologies/bs-Zarith
Support Bigint, Q (rational numbers) and Z (integer numbers) in BuckleScript.
https://github.com/plow-technologies/bs-Zarith
bs-zarith bucklescript integer reasonml zarith
Last synced: 8 months ago
JSON representation
Support Bigint, Q (rational numbers) and Z (integer numbers) in BuckleScript.
- Host: GitHub
- URL: https://github.com/plow-technologies/bs-Zarith
- Owner: plow-technologies
- Created: 2018-05-17T04:24:09.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-02T18:02:52.000Z (about 3 years ago)
- Last Synced: 2024-10-31T18:08:38.653Z (about 1 year ago)
- Topics: bs-zarith, bucklescript, integer, reasonml, zarith
- Language: JavaScript
- Homepage:
- Size: 397 KB
- Stars: 15
- Watchers: 13
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
Awesome Lists containing this project
- awesome-list - bs-Zarith - technologies | 15 | (JavaScript)
README
# bs-zarith
The API is stable, but there is not a lot of testing. Use with caution.
## Bigint
```OCaml
let x = Bigint.of_string "1000000000000000000000000000000000000000" in
let y = Bigint.of_int 1 in
let z = Bigint.(y + x) in
Js.log(Bigint.to_string(z));
```
## Z
```
let x = Z.Int64.of_string "230000232323322323" in
let y = Z.Int64.of_int 3 in
let z = Z.Int64.(x - y) in
Js.log(Z.Int64.to_string(z));
```
## Q
```
let x = Q.Int.of_string "1/2" in
let y = Q.Int.make (Z.Int.one) (Z.Int.of_int 2)
let z = Q.Int.sub x y
Js.log(Q.Int.to_string(z));
```