java使用arity计算器引擎

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package com.empty.calculator;

import org.javia.arity.Symbols;
import org.javia.arity.SyntaxException;
import org.junit.Test;


* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/

public class {


public void testExpresion() throws SyntaxException {
Symbols symbols = new Symbols();
//直接把表达式放进去
double result=symbols.eval("1+2/3");
System.out.println(""+result);
}

}

arity下载地址: https://raw.githubusercontent.com/Emptying/Calculator/master/app/libs/arity-2.1.2.jar
具体使用例子 https://github.com/Emptying/Calculator