Skip to content

Fix default format(float) result when the number is too big #2307

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

Merged
merged 4 commits into from
Oct 26, 2020

Conversation

ChJR
Copy link
Contributor

@ChJR ChJR commented Oct 25, 2020

Before this change, format(1e16) returns '10000000000000000.0' in RustPython while CPython 3.7 returns '1e+16'.
After this change, format(1e16) returns '1e+16' in RustPython too.

ChJR added 2 commits October 26, 2020 00:27
Before this change, format(1e16) returns '10000000000000000.0' in RustPython while CPython 3.7 returns '1e+16'.
After this change, format(1e16) returns '1e+16' in RustPython too.
Copy link
Member

@coolreader18 coolreader18 left a comment

Choose a reason for hiding this comment

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

Nice work!

vm/src/format.rs Outdated
Comment on lines 407 to 408
// Using the Debug format here to prevent the automatic conversion of floats
// ending in .0 to their integer representation (e.g., 1.0 -> 1)
Copy link
Member

Choose a reason for hiding this comment

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

You could probably remove this explanation, since it doesn't apply anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good points!

@coolreader18
Copy link
Member

Thanks for contributing!

@coolreader18 coolreader18 merged commit 0aa177d into RustPython:master Oct 26, 2020
@ChJR ChJR deleted the feature/format_float branch October 30, 2020 14:23
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