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

Fix parsing numbers #299

Merged
merged 3 commits into from
May 29, 2024
Merged

Conversation

sideeffffect
Copy link
Contributor

Use java.lang.Integer.decode which handles other radices besides 10

Also remove _ from the number string

Use java.lang.Integer.decode which handles other radices besides 10

Also remove `_` from the number string
Try(Integer.parseInt(value.drop(2), 8)).toEither.left
.map(t => ConstructError.from(t, "Int", node))
else if (value.startsWith("0x"))
Try(Integer.parseInt(value.drop(2), 8)).toEither.left
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8 instead of 16.

But it's better to leave it to Long.decode anyway.

Copy link
Member

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! I see that there is a failed test, could you take a look at it?

@sideeffffect
Copy link
Contributor Author

@tgodzik should be good now. Can you please run the CI workflow? 🙏

Copy link
Member

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

@tgodzik tgodzik merged commit 523ce9b into VirtusLab:main May 29, 2024
6 checks passed
@sideeffffect sideeffffect deleted the fix-parsing-numbers branch May 29, 2024 13:33
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.

None yet

2 participants