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

Alignment of floating-point numbers is incorrect if the output is localized and the integer part is zero #3263

Closed
intractabilis opened this issue Jan 6, 2023 · 0 comments · Fixed by #3272

Comments

@intractabilis
Copy link

Consider the following code (https://godbolt.org/z/f7czaGcdG):

#include <locale>
#include <fmt/printf.h>

int main(int argc, char* argv[]) {
    std::locale::global(std::locale("en_US.UTF-8"));

    fmt::print("     X = {:19.3Lf}\n", -119.921);
    fmt::print("     Y = {:19.3Lf}\n", 2'194.139);
    fmt::print("     Z = {:19.3Lf}\n", -57.639);
    fmt::print("    VX = {:19.3Lf}\n", -5.980);
    fmt::print("    VY = {:19.3Lf}\n", -2.119);
    fmt::print("    VZ = {:19.3Lf}\n", 0.295);
}

The last number will be misaligned in the output:

     X =           -119.921
     Y =          2,194.139
     Z =            -57.639
    VX =             -5.980
    VY =             -2.119
    VZ =               0.295

If you change the last number to 1.295, the alignment will be correct. It is also correct if you remove L.

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 a pull request may close this issue.

1 participant