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

Incorrect number reading #125

Closed
josefblaha opened this issue Sep 5, 2024 · 1 comment · Fixed by #126
Closed

Incorrect number reading #125

josefblaha opened this issue Sep 5, 2024 · 1 comment · Fixed by #126

Comments

@josefblaha
Copy link

There is a case where Mages incorrectly tokenizes a number. Some cases were fixed in #110, but not all of them.

Steps to reproduce

Start REPL and evaluate the following numbers:

SWM> 0.8409014139716477191
0.8409014139716476
SWM> 0.84090141397164771912
0.10303165102326567

The first number correctly evaluated, losing precision as expected.
The second number (just adding 2 to the end) produces distorted result.

Environment

Mages 3.0.0
Windows 11

Cause

Since #110, the NumberTokenizer.AddValue method checks for some overflow cases, but not all of them. Specifically for the example number above it all goes well until the attempt to add the last digit 2:
image
The overflown newValue = 10303165102326565448 is larger than _value = 8409014139716477191, therefore it's not ignored.

Fix proposal

We should improve the overflow check. I will create a PR soon with a proposed fix.

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 a pull request may close this issue.

2 participants
@josefblaha and others