Skip to content

Conversation

manuelvcr
Copy link

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.

BigDecimal.remainder for decimal values and avoid wrong results when we
use the MOD or MODULO function with large numbers.
@mariuszgromada
Copy link
Owner

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)");

@manuelvcr
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants