Skip to content

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

Open
manuelvcr wants to merge 1 commit intomariuszgromada:masterfrom
manuelvcr:master
Open

Updated to use BigInteger.mod function for integer values, or#132
manuelvcr wants to merge 1 commit intomariuszgromada:masterfrom
manuelvcr:master

Conversation

@manuelvcr
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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