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 printf float with with many digits #10719

Merged

Conversation

straight-shoota
Copy link
Member

Resolves #10714

@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:numeric labels May 16, 2021
@@ -269,7 +269,7 @@ struct String::Formatter(A)

format_buf = recreate_float_format_string(flags)

len = flags.width + (flags.precision || 0) + 23
len = LibC.snprintf(nil, 0, format_buf, float) + 1
temp_buf = temp_buf(len)
count = LibC.snprintf(temp_buf, len, format_buf, float)
Copy link
Contributor

Choose a reason for hiding this comment

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

count is always len - 1 so we don't need this variable anymore

@asterite asterite merged commit 08c6638 into crystal-lang:master Jun 2, 2021
@straight-shoota straight-shoota deleted the fix/string-format-float branch June 2, 2021 10:40
@bcardiff bcardiff added this to the 1.1.0 milestone Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:numeric
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Float string interpolation prints some null characters
4 participants