An open API service indexing awesome lists of open source software.

https://github.com/june-it/mystack.formula

实现数学公式逻辑运算,支持数据源值计算。
https://github.com/june-it/mystack.formula

farmula

Last synced: about 2 months ago
JSON representation

实现数学公式逻辑运算,支持数据源值计算。

Awesome Lists containing this project

README

        

# MyStack.Formula
公式运算

## 调用方式
```
// 服务注入
var services = new ServiceCollection();
services.AddFormula(context.Configuration, configure =>
{
// 配置JSON数据源
configure.UseConfigurationIdValue();
});

```

## 功能
```
// 调用
var formulaEngine = serviceProvider.GetRequiredService();
```

### 运算符 `+`、`-`、`*`、`/`、`^`
```
// 结果:2
var actualValue = formulaEngine.Calculate("1+1");
```

### 括号符

```
// 结果:4
var actualValue = formulaEngine.Calculate("(1+1)*2");
```

### 复杂公式

```
// 调用
// 结果:9.001953125
var actualValue = formulaEngine.Calculate("3+4*2/(1-5)^2^3+2*(2+1)");
```

### 三角函数
```
// 调用
// 结果:1024
var actualValue = formulaEngine.Calculate("COS(900-3*10*30)+123.45+30*30-0.45+TAN(0)");
```

### 数据源

#### 值类型计算

```
// 配置Id的值为:<1> = 1
// 结果:4
var actualValue = formulaEngine.Calculate("(1+<1>)*2");

```
#### 公式类型计算
```
// 配置Id的值为:<2> = (2+1)*2
// 结果:22
var actualValue = formulaEngine.Calculate("(1+<1>)*2");

```