Я использую Rhino Library, чтобы оценить строку в Android Studio. При этом я получил сообщение об ошибке, приложение вылетает при умножении десятичных чисел
Десятичные дроби, как 3,08 * 23 или 45 + 3,10. Обратите внимание, что если я делаю 3,0 * 67, то он не падает
Вот мой метод оценки
public static Object eval(final String str) {
Object result;
try {
final String simpleAdd = str;
Context jsCx = Context.enter();
Context.getCurrentContext().setOptimizationLevel(-1);
ScriptableObject scope = jsCx.initStandardObjects();
result = jsCx.evaluateString(scope, simpleAdd , "formula", 0, null);
Context.exit();
}catch (Exception e){
return 08998.097;
}
if(result == "Infinity"){
return 08998.097;
}
return result;
}
И это мой метод, который происходит при нажатии кнопки '='
if(textArea.getText().toString().contains("=")){
textArea.setText(textArea.getText().toString());
word = result;
if(spinner.getSelectedItem().equals("English")) {
TextView tv = (TextView) findViewById(R.id.tv);
tv.setText(EnglishNumberToWords.convert((long) word));
}else if(spinner.getSelectedItem().equals("German")){
TextView tv = (TextView) findViewById(R.id.tv);
tv.setText(GermanNumberToWords.convert((long) word));
}else{
tv.setText(SpanishNumberToWords.convert((long) word));
}
return;
}
String text1 = textArea.getText().toString()
result = (double)(AdvancedCalculator.eval(text1));
//ToDo ssss
if(result==08998.097){
errorMessageText.setVisibility(View.VISIBLE);
textArea.setText("");
tv.setText("");
return;
}
DecimalFormat decimalFormat = new DecimalFormat("0.###");
String string = decimalFormat.format(result);
result = Long.parseLong(string);
word = result;
textArea.setText(textArea.getText().toString() + " = " + result);
if(spinner.getSelectedItem().equals("English")) {
TextView tv = (TextView) findViewById(R.id.tv);
tv.setText(EnglishNumberToWords.convert((long) word));
}else if(spinner.getSelectedItem().equals("German")){
TextView tv = (TextView) findViewById(R.id.tv);
tv.setText(GermanNumberToWords.convert((long) word));
}else{
tv.setText(SpanishNumberToWords.convert((long) word));
}
Всякий раз, когда я пытаюсь оперировать десятичными знаками, он падает, но работает нормально, если это не означает, что я не использую десятичные дроби (за исключением наличия символа '.0' в конце)