Evaluate mathematical expression within string

倾然丶 夕夏残阳落幕 提交于 2019-12-25 08:57:13

问题


I'm developing an Android app that i get an String with the mathematical expression i have to calculate, i did it to convert the letters into the numbers i need, but what is the best way to evaluate this?

Nothing too complicated, the formulas are like those: ((A * 2 + B * 3 + C * 5) / 10) + D

EDIT: Just found that guy, very simple API, works like a charm http://code.google.com/p/symja/wiki/MathExpressionParser


回答1:


You want some sort of math parser.

Fun to roll your own, or there are plenty of hits on google: https://www.google.co.uk/#hl=en&gs_nf=1&cp=16&gs_id=7&xhr=t&q=java+math+parser



来源:https://stackoverflow.com/questions/10704885/evaluate-mathematical-expression-within-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!