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

[Bug] Wrong result for numbers more than 16 digits #27

Open
Sp4Rx opened this issue Jul 23, 2020 · 1 comment
Open

[Bug] Wrong result for numbers more than 16 digits #27

Sp4Rx opened this issue Jul 23, 2020 · 1 comment
Labels
bug Indicates an unexpected problem or unintended behavior documentation Indicates a need for improvements or additions to documentation

Comments

@Sp4Rx
Copy link

Sp4Rx commented Jul 23, 2020

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.

@fkleon
Copy link
Owner

fkleon commented Jul 24, 2020

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.

@fkleon fkleon added bug Indicates an unexpected problem or unintended behavior documentation Indicates a need for improvements or additions to documentation labels Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior documentation Indicates a need for improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants