posts - 431,  comments - 344,  trackbacks - 0
           JEP是java數學解析器的一個開源工具,解析并計算與數學運算相關的字符串的一個類庫,是java數學解析器的一個開源工具,提供第三方的jar包只要將jar包放到lib目錄下即可使用

          簡單示例:

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

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

          具體更復雜的操作可以參看下載的zip中\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 周銳 閱讀(1414) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 建阳市| 滁州市| 河间市| 壤塘县| 辽源市| 万荣县| 肇州县| 大渡口区| 枣庄市| 崇信县| 边坝县| 新和县| 太和县| 克什克腾旗| 祁连县| 筠连县| 马鞍山市| 临澧县| 胶州市| 五原县| 萨嘎县| 宾川县| 友谊县| 道孚县| 阳原县| 望城县| 抚宁县| 晋江市| 什邡市| 嘉义县| 明光市| 防城港市| 盐池县| 泰来县| 新建县| 炎陵县| 新津县| 常宁市| 郯城县| 巴彦县| 金华市|