Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to use BigInteger.mod function for integer values, or #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

None yet

2 participants