math-expressions
math-expressions copied to clipboard
[Bug] Wrong result for numbers more than 16 digits
Wrong result comes for numbers more than 16 digits. For example
Expression expression = Parser().parse('88888888888888888');
print(expression.toString());
Expected result should be 88888888888888888
but we get 88888888888888900.0
which is wrong.
NB: This happens for each and every number.
If possible, please provide a resolution ASAP as I'm using it in my production app.
Hi @Sp4Rx, thanks for the report.
You are running into a limitation of the datatype that is used to represent numbers within this library. Numbers are handled as regular double values which are 64 bit double-precision floating point numbers. They only offer roughly up to 15 digits of precision.
This could be improved by utilising a big decimal representation, for example as implemented by decimal.
I don't have plans to implement this anytime soon, but contributions are welcome.