a-calc
A string of four operations of the library, can solve the js digital calculation accuracy of scientific notation and formatting problems, support for thousands of decimal point formatting output operations
(一个字符串四则运算的库, 可以解决js数字计算精度 科学记数法和格式化的问题, 支持千分位小数点格式化输出等操作)
Supported operators (支持的运算符) : + - * / %
Install(安装)
npm install a-calc
Import(引入)
commonjs
const {calc, fmt} = require("a-calc")
es module
import {calc, fmt} from "a-calc"
browser
<script src="node_modules/a-calc/browser/index.js"></script>
<script>
const {calc, fmt} = a_calc
</script>
Calculate(计算)
calc("0.1 + 0.2")
calc`0.1 + 0.2`
calc("0.1 + 0.2 * 0.3 / 0.4 * (0.5 + 0.6)")
Fill and calculate(填充变量并计算)
let a = 0.000001
let b = 888.789
calc("a + b", {a,b})
Calculate & Format (计算并格式化)
calc("0.1 + 0.2 | =2")
calc("0.11111 + 0.11111 | <=4")
calc("0.11 + 0.11 | <=4")
calc("0.1 + 0.2 | >= 5")
calc("0.0000001+ 0.0000001 | >= 5")
calc("10000000 + 100000000 | ,")
calc("10000000 + 100000000 | =10 ,")
Only Format(只格式化)
calc("0.1 | =2")
fmt("0.1 | =2")
fmt("1000000 | ,")
Attention(注意)
- Do not wrap parentheses around single numbers (不要对单个数字包裹括号)
Video Tutorial(视频教程)
待定
Issue To(问题提交)
If you have any questions, pstlease send email to 718879459@qq.com as soon as possible to give me feedback
(如果遇到了什么问题, 请第一时间向我发送反馈邮件, 718879459@qq.com 对于bug我会第一时间修复他)