-
Notifications
You must be signed in to change notification settings - Fork 9
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
int.toString().interpret() returns a num of type double not int #6
Comments
You can parse the output to a string and 'regex it away' :) // get ints without comma
final result = "1 + 1".interpret();
print(result.toString().replaceAll(RegExp(r'\.0+\b'), ""));
// get ints in LaTeX equation without commas
final equationAsTex = "1 + 1".interpret()
.toString()
.toSingleVariableFunction()
.tex;
print(equationAsTex.replaceAll(RegExp(r'\.0+\b'), "")); btw. this |
Thanks for your interest in this library! Actually, If you want, however, you can change this behavior by changing line 62 of final x = double.tryParse(expression); to final x = num.tryParse(expression); Hope that helps! |
Instead of users doing this, you can add this logic to check if the answer of interpret() is equal to interpret ().toInt(), then return answer.toInt() else answer. So for 1.2, the above logic will return 1.2 not 1 |
Thanks for the idea. There's no need to do the check, though: In any case, it looks as though it's pretty easy to force a result to be an int when that is what is desired, but in most use cases, it either doesn't matter whether the output is an int or a double, or the desired output is a double. |
The output of "1".interpret() should be 1 but it come as 1.0
Similary for "1+1".interpret(), the output is 2.0 but it should be 2
The text was updated successfully, but these errors were encountered: