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

improve precision of float.to_precision #785

Merged
merged 1 commit into from
Jan 3, 2025

Conversation

joshi-monster
Copy link
Contributor

@joshi-monster joshi-monster commented Jan 2, 2025

significantly improve the precision when rounding with a positive precision. while factors greater than one can be accurately represented up to a large number (10, 100, 1000, ...), even a factor of 0.1 already introduces inaccuracies, since 0.1 cannot be accurately represented using floating-point numbers.

The added test cases show this behaviour; one of them always fails if both branches of the case were the same.

~ 💜

Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

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

Thank you

@lpil lpil merged commit 619935a into gleam-lang:main Jan 3, 2025
7 checks passed
@joshi-monster joshi-monster deleted the to_precision branch January 3, 2025 21:07
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.

2 participants