是否有关于Android的数学EX pression解析库?数学、Android、pression、EX

由网友(酒煙妓)分享简介:目前我已经在iOS上,我希望端口到Android的应用程序。该应用程序使用的Objective-C GCMathParser 框架/班。 Currently I have an app on iOS that I am looking to port to Android. This app uses the Ob...

目前我已经在iOS上,我希望端口到Android的应用程序。该应用程序使用的Objective-C GCMathParser 框架/班。

Currently I have an app on iOS that I am looking to port to Android. This app uses the Objective-C GCMathParser framework/class.

我要寻找在Android更换(或方法,使在Android GCMathParser工作),这将是能够计算的东西,如:

I am looking for a replacement on Android (or a way to make GCMathParser work on Android) that would be able to calculate stuff like:

2*2

(2+3)+2

((2+3)+2)/5

(-2 + sqrt((-5^2)-4*2*3))/(2 * 2) 

我想能够养活一个字符串到这个(如上),并得到一个结果,preferably相对precise(如双)。

I would like to be able to feed a String into this (like above) and get back a result, preferably relatively precise (like double).

我有什么选择解析数学EX pressions这样在Android?

What options do I have for parsing mathematical expressions like this on Android?

推荐答案

怎么样的 MVEL ?

Map vars = new HashMap();
vars.put("x", new Integer(5));
vars.put("y", new Integer(10));

Integer result = (Integer) MVEL.eval("x * y", vars);

您也可以使用它在普通的Java调用,例如的Math.sqrt(...)

You could also use plain Java calls in it like Math.sqrt(...)

阅读全文

相关推荐

最新文章