zms / calculation
计算器
v1.0.0
2025-03-19 06:58 UTC
Requires
- php: >=7.0
This package is not auto-updated.
Last update: 2025-04-03 05:18:11 UTC
README
介绍
四则运算计算器,逆波兰算法出现问题太多,改为四则运算配合高精度计算函数
安装教程
composer require zms/calculation
使用说明
<?php
declare(strict_types=1);
use Zms\Calculation\Calculation;
use function \Zms\Calculation\compute;
//也可以直接是用函数compute
Calculation::compute('1*2(112+12+(12-10+(-13-10+(-10-23))))/10+12(13-4)')
compute('1*2(112+12+(12-10+(-13-10+(-10-23))))/10+12(13-4)')
结果:122
Calculation::compute('1*6/2+13+(12+8*7-10)-3+((1+1)*(4/2))-(12-23)')
结果:86
Calculation::compute('1*6/2+13+58-3+4')
结果:75
Calculation::compute('-5-3+2-(-10)+(-15)')
结果:-11
Calculation::compute('1.1+2.4*-5')
结果:-10.9
Calculation::compute('1+5-3')
结果:3
Calculation::compute('-1*-6')
结果:6
Calculation::compute('0/100')
结果:0
Calculation::compute('1+232.23')
结果:233.23
Calculation::compute('23*6')
结果:138
Calculation::compute('34/2')
结果:17
Calculation::compute('(34-242)')
结果:-208
Calculation::compute('1.1+2.9/3')
结果:2.0666666666