Android 如何在exp4j编译器java中定义Ln

Android 如何在exp4j编译器java中定义Ln,android,calculator,Android,Calculator,我正在制作android计算器,所以我想在exp4j编译器中定义Ln(2.303*Math.log10(number)): 但我不想手动输入数字,所有操作都存储在字符串结果中 因此,当您看到Ln执行此操作时,我想告诉编译器(2.303*Math.log10(number)) 为什么要使用粗略近似值而不是?Log不同于LnMath。Log是自然对数。你声称Ln是什么?@rici我把函数放在Ln上(2.303*log10(数字)) String txt = txt_Screen.getText().

我正在制作android计算器,所以我想在exp4j编译器中定义Ln(2.303*Math.log10(number)):

但我不想手动输入数字,所有操作都存储在字符串结果中 因此,当您看到Ln执行此操作时,我想告诉编译器(2.303*Math.log10(number))


为什么要使用粗略近似值而不是?Log不同于LnMath。Log是自然对数。你声称Ln是什么?@rici我把函数放在Ln上(2.303*log10(数字))
String txt = txt_Screen.getText().toString();


    try {
        // Calculate the result and display
       // if(txt.contains("ln")) {
         //   txt.replace("ln",)
        Expression expression = new ExpressionBuilder(txt).build();
        double result = expression.evaluate();
        if ((result == Math.floor(result)) && !Double.isInfinite(result)) {


            result_Screen.setText((int) result + "");
        }else
            result_Screen.setText(result+"");


       // double result = expression.evaluate();



    } catch (Exception ex) {
        txt_Screen.setText("Syntax Error");

    }
    String txt = txt_Screen.getText().toString();


try {
    // Calculate the result and display
   // if(txt.contains("ln")) {
     //   txt.replace("ln",)

 **Function ln = new Function("ln", 1) {
 @Override
 public double apply(double... args) {
    return 2.303*Math.log10(args[0]);
 }
 };**
    Expression expression = new 
ExpressionBuilder(txt).**function(ln)**.build();
    double result = expression.evaluate();
    if ((result == Math.floor(result)) && !Double.isInfinite(result)) {


        result_Screen.setText((int) result + "");
    }else
        result_Screen.setText(result+"");


   // double result = expression.evaluate();



} catch (Exception ex) {
    txt_Screen.setText("Syntax Error");

}