I use the third-party library org.nfunk.jep . But all calculations inside this library are made in double , regardless of what type the input variables had, since the addVariable method in the JEP class can only accept variables of the following types as input:
For example, when I execute the following code:
BigDecimal value1 = new BigDecimal("29250.24"); BigDecimal value2 = new BigDecimal("263.21"); JEP calc = new JEP(); calc.addVariable("var1", Double.parseDouble(value1)); calc.addVariable("var2", Double.parseDouble(value2)); calc.parseExpression("var1 - var2"); System.out.println("Результат: " + calc.getValue()); I want to get "28987.03", but in reality the output is:
Result: 28987.0300000002
Maybe someone knows how to work with this library and BigDecimal or knows similar libraries that work with BigDecimal type numbers?
