MathParser.org-mXparser
MathParser.org-mXparser copied to clipboard
Updated to use BigInteger.mod function for integer values, or
Updated to use BigInteger.mod function for integer values, or BigDecimal.remainder for decimal values and avoid wrong results when we use the MOD or MODULO function with large numbers.
You are using tokenString - this will not work in general case, tokeString are available onlyh at the beginning, modulo function can be called also with parameters that are results of further calculations, i.e.
Expression e = new Expression("mod(2^3+sin(pi), 4*3)");
Hi, so we can change code to user tokenValue instead of tokenString:
private String getTokenValueAsString (int tokenIndex) {
return Double.toString(tokensList.get(tokenIndex).tokenValue);
}
I can check if result of module is same that using my first implementation.