posts - 431,  comments - 344,  trackbacks - 0
           JEP是java數(shù)學(xué)解析器的一個(gè)開源工具,解析并計(jì)算與數(shù)學(xué)運(yùn)算相關(guān)的字符串的一個(gè)類庫(kù),是java數(shù)學(xué)解析器的一個(gè)開源工具,提供第三方的jar包只要將jar包放到lib目錄下即可使用

          簡(jiǎn)單示例:

          import com.singularsys.jep.Jep;
          import com.singularsys.jep.JepException;

          public class SimpleExample {
              public static void main(String[] args) {
                  Jep jep = new Jep();
                  //一個(gè)數(shù)學(xué)表達(dá)式
                  String exp = "((a+b)*(c+b))/(c+a)/b";
                  //給變量賦值
                  jep.addVariable("a", 10);
                  jep.addVariable("b", 10);
                  jep.addVariable("c", 10);
           
                 try {
                     //執(zhí)行
                     jep.parse(exp);
                     Object result = jep.evaluate();
                     System.out.println("計(jì)算結(jié)果: " + result);
                  } catch (JepException e) {
                      System.out.println("An error occured: " + e.getMessage());
                  }
              }
          }

          具體更復(fù)雜的操作可以參看下載的zip中\(zhòng)doc\html\index.html

          Jep is a Java library for parsing and evaluating mathematical expressions. With this package you can allow your users to enter an arbitrary formula as a string, and instantly evaluate it. Jep supports user defined variables, constants, and functions. A number of common mathematical functions and constants are included.
          參考資料:http://www.singularsys.com/jep/doc/html/index.html
          posted on 2009-06-17 10:54 周銳 閱讀(1406) 評(píng)論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 仪征市| 桐梓县| 陇西县| 巴东县| 黄骅市| 霸州市| 黄梅县| 内江市| 无锡市| 志丹县| 双峰县| 甘南县| 滦南县| SHOW| 东阳市| 房产| 洪泽县| 樟树市| 都昌县| 三台县| 普定县| 湄潭县| 慈利县| 林州市| 恩平市| 淅川县| 玉山县| 呈贡县| 乐陵市| 兴国县| 中卫市| 得荣县| 赤水市| 龙南县| 富顺县| 武川县| 贵德县| 桦川县| 凤凰县| 凤山市| 海林市|