posts - 431,  comments - 344,  trackbacks - 0
           JEP是java數(shù)學(xué)解析器的一個(gè)開(kāi)源工具,解析并計(jì)算與數(shù)學(xué)運(yùn)算相關(guān)的字符串的一個(gè)類庫(kù),是java數(shù)學(xué)解析器的一個(gè)開(kāi)源工具,提供第三方的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 周銳 閱讀(1415) 評(píng)論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 武穴市| 宜城市| 中阳县| 长葛市| 合水县| 双城市| 凤庆县| 台州市| 武穴市| 黄骅市| 高唐县| 呼图壁县| 柘荣县| 乌海市| 鄂州市| 河池市| 弥勒县| 曲水县| 都江堰市| 通山县| 浦东新区| 平果县| 宁远县| 应城市| 平阳县| 曲麻莱县| 蓬莱市| 东乌珠穆沁旗| 鲁山县| 临江市| 镇雄县| 通化县| 扶沟县| 图木舒克市| 花莲县| 南开区| 梅河口市| 巨野县| 济宁市| 浦东新区| 衡南县|