Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/winoteam-archives/rescript-big
🎡 Zero-cost bindings to Big.js library.
https://github.com/winoteam-archives/rescript-big
bigjs decimals ocaml reasonml rescript rescript-binding
Last synced: 2 days ago
JSON representation
🎡 Zero-cost bindings to Big.js library.
- Host: GitHub
- URL: https://github.com/winoteam-archives/rescript-big
- Owner: winoteam-archives
- License: mit
- Archived: true
- Created: 2020-03-20T14:26:02.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T04:36:11.000Z (about 2 years ago)
- Last Synced: 2024-09-25T23:11:02.416Z (4 months ago)
- Topics: bigjs, decimals, ocaml, reasonml, rescript, rescript-binding
- Language: ReScript
- Homepage: https://github.com/winoteam/rescript-big
- Size: 354 KB
- Stars: 5
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rescript-big
[![Actions Status](https://github.com/winoteam/rescript-big/workflows/rescript-big/badge.svg)](https://github.com/winoteam/rescript-big/actions)
**Zero-cost bindings to [Big.js](https://github.com/MikeMcl/big.js/) library.**
In this version only these methods are supported: `toFixed`, `plus`, `minus`, `div`, `times`, `valueOf`, `round`, `eq`, `gt`, `gte`, `lt` and `lte`
It also have some converters and shortcuts for converting an existing value or making a Big value, such as: `fromFloat`or `toFloat`.
It's accompanied with an `Operators` module which override some operators like `+.`, `*.`, `/.` and `-.`
## 📦 Installation
Run the following command:
```bash
$ yarn add rescript-big
```Then add `rescript-big` to your `bsconfig.json`'s dependencies:
```diff
{
"bs-dependencies": [
+ "rescript-big"
]
}
```## 💻 Usage
```rescript
open! Big.Operatorslet a = 201.57512->Big.fromFloat
Js.log(a->Big.toFixed(2)) // 201.58// Compiler error: 1. is a float, wanted Big.t
let c = a *. 1.// OK
let b = 1.->Big.fromFloat
let c = a *. b
Js.log(Big.valueOf(c)) // 201.57512
```## 🕺 Contribute
### 🚀 Want to hack on `rescript-big`? Follow the next instructions
1. Fork this repository to your own GitHub account and then clone it to your local device
2. Install dependencies using Yarn: `yarn`
3. Ensure that the tests are passing using `yarn test`
4. Send a pull request 🙌Remember to add tests for your change if possible.
## 👋 Questions
If you have any questions, feel free to open an issue. Please check the [Big.js docs](https://github.com/MikeMcl/big.js/) before submitting an issue.