1 个不稳定版本
| 0.1.0 | 2023年11月14日 |
|---|
#67 in #arithmetic
92KB
703 行
roundme
roundme 是一个实验性的人工辅助舍入分析器。它旨在提供建议以确定算术运算应向上舍入还是向下舍入
安装
使用方法
cargo install roundme
使用 roundme init 命令生成默认配置文件。
git clone git@github.com:crytic/roundme.git
cd roundme
cargo install --path .
如何使用
- 运行
roundme init以生成默认配置文件。 - 运行
roundme config以生成用户配置文件。 - 运行
roundme analyze以分析配置文件 - 运行
roundme pdf以生成 PDF(需要latexmk)
在默认配置上运行 roundme pdf 将生成以下内容: 
配置
roundme 依赖于配置文件
formula: a * b / c
round_up: true
less_than_one: ["a * b"] # optional
greater_than_one: ["c"] # optional
formula包含要分析的公式round_up确定公式的结果是否应该向上舍入或向下舍入less_than_one用于**规则 (原始字符串比较和敏感于空格)greater_than_one用于**规则 (原始字符串比较和敏感于空格)
请参阅 balancer V2 示例。
功能
- 推荐需要进行舍入或舍入的算术运算
- 生成基于 LaTeX 的 PDF 报告
规则
rounding() 是结果预期的舍入方向(向上或向下)
A + B => rounding(A), rounding(B)(加法不改变舍入方向)A - B => rounding(A), ! rounding(B)(被减去元素的舍入方向与预期舍入相反)A * B => rounding(A), rounding(B), rounding(*)(乘法不改变舍入方向)A / B => rounding(A), ! rounding(B), rounding(/)(分母的舍入方向是预期舍入方向的相反)A**B如果 A>=1 => 舍入(A), 舍入(B)如果 A<1 => rounding(A), ! rounding(B)(如果 A 小于 1,指数的舍入方向是预期舍入方向的相反)
依赖关系
~5–8.5MB
~147K SLoC