# @chewbank/ecalculator

> 浮点数运算器

Latest version **1.0.1** (published 2020-11-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install @chewbank/ecalculator
pnpm add @chewbank/ecalculator
yarn add @chewbank/ecalculator
bun add @chewbank/ecalculator
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-11-20 |
| First published | 2020-11-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | vipzhicheng |
| Keywords | 浮点运算, js浮点数, js float |

## Links

- npm: https://www.npmjs.com/package/@chewbank/ecalculator
- npm.io page: https://npm.io/package/@chewbank/ecalculator

## Recent versions

- 1.0.1 (latest) — 2020-11-20

## README

采用数组表达式的浮点数运算器，类似数学运算表达式语法，实现浮点数的连续运算

## Install

      npm install ecalculator --save

## 示例

```js
const calculator = require('ecalculator')

const result = calculator(0.1, '+', 0.2, '+', 0.3)
// 0.6 | 0.6000000000000001

const result = calculator(0.1, '+', 0.2, '+', [0.3, '*', 0.4])
// 0.42 | 0.42000000000000004

const result = calculator(0.1, '-', 0.2, '+', [0.3, '/', 0.4])
// 0.65 | 0.6499999999999999

const result = calculator(0.1, '+', 0.2, '+', [0.2, '*', [0.3, '/', 0.4]])
// 0.45 | 0.45000000000000007
```

## 优先级

> 注意：不支持自动提升乘除法优先级，可使用数组包裹方式声明优先级。

数组等同于括弧，与括弧运算符特性一致。


## 关于精度

加减乘除运算均采用放大至整型后求值，当除法运算无法被除尽时依然会产生多位小数，输出特性与普通计算器一致

---
_Source: https://npm.io/package/@chewbank/ecalculator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
