-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Unable to print floating point in current locale #1291
Comments
The reason the second line prints
Looks like floating-point 'n' is missing from the docs though - I need to fix that. |
Is there any way with 'n' to print with a specified number of places always? For instance, I need to always display 2 decimals (no matter how large the number is) - even for a number like 2.1 (which should display as 2.10). |
You can request to output trailing zeros with auto s = fmt::format("{:#.3n}", 2.1); // s == "2.10" |
The 'n' specifier is documented now: https://fmt.dev/dev/syntax.html |
Since fmt has switched to locale-independent, it's not possible to print floating point in a specific locale with specific formatting.
The first line works (locale-independent). The 2nd prints 3.1
Edit: I just noticed it appears to be an off-by-one issue.
will print 3.14
The text was updated successfully, but these errors were encountered: