https://github.com/crytic/roundme
https://github.com/crytic/roundme
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/crytic/roundme
- Owner: crytic
- License: agpl-3.0
- Created: 2023-11-14T06:59:31.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-31T12:43:19.000Z (about 2 years ago)
- Last Synced: 2025-04-06T15:06:33.745Z (about 1 year ago)
- Language: Rust
- Size: 202 KB
- Stars: 91
- Watchers: 2
- Forks: 7
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# roundme
`roundme` is a human-assisted rounding analyzer. It helps its operator determine whether an arithmetic operation should round up or down.
## Features
- Recommends whether an arithmetic operation needs to round up or down
- Generates LaTeX-based reports in PDF
## Rules
`rounding()` is the expected rounding direction for the result (up or down)
- `A + B => rounding(A), rounding(B)` (addition does not change the rounding direction)
- `A - B => rounding(A), ! rounding(B)` (the rounding direction of the substracted element is inverse of the expected rounding)
- `A * B => rounding(A), rounding(B), rounding(*) ` (multiplication does not change the rounding direction)
- `A / B => rounding(A), ! rounding(B), rounding(/)` (the rounding direction of the denominator is the inverse of the expected rounding)
- `A ** B`
- `If A>=1 => rounding(A), rounding(B)`
- `If A<1 => rounding(A), ! rounding(B)` (if A is below 1, the rounding direction of the exponent is the inverse of the expected rounding)
## How to use
- Run `roundme init-sample` to generate a default configuration file.
- Run `roundme init` to generate user configuration file.
- Run `roundme analyze` to analyze the configuration file
- Run `roundme analyze --output-format pdf` to generate a PDF (require [latexmk](https://mg.readthedocs.io/latexmk.html))
Running `roundme analyze --output-format pdf` on the default configuration will generate the following:

### Configuration
`roundme` relies on a configuration file:
```yaml
formula: a * b / c
round_up: true
less_than_one: ["a * b"] # optional
greater_than_one: ["c"] # optional
```
- `formula` contains the formula to be analyze
- `round_up` determines if the result of the formula should round up or down
- `less_than_one` is used for the `**` [rules](#rules) *(raw string comparison and sensible to space)*
- `greater_than_one` is used for the `**` [rules](#rules) *(raw string comparison and sensible to space)*
See the [balancer V2](./examples/balancer/README.md) example.
## Install
Install with
```bash
cargo install roundme
```
To install the latest GitHub version
```bash
git clone git@github.com:crytic/roundme.git
cd roundme
cargo install --path .
```