You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Revealed by libc++ test std/utilities/format/format.functions/locale-specific_form.pass.cpp.
When formatting a floating-point number, digit separators are not taken into account when computing the width of output, which may cause too many fill characters in the output.
For integers, digit separators are correctly handled:
D:\test>type test-format.cpp
#include <format>
#include <iostream>
int main() {
std::cout << std::format(std::locale("en_US"), "{:@>8L}\n", 12345);
std::cout << std::format(std::locale("en_US"), "{:@>8L}\n", 12345.0);
}
D:\test>cl /std:c++20 /utf-8 /EHs test-format.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.39.33321 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
test-format.cpp
Microsoft (R) Incremental Linker Version 14.39.33321.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:test-format.exe
test-format.obj
D:\test>test-format.exe
@@12,345
@@@12,345
Expected behavior
The output should be @@12,345 instead of @@@12,345.
StephanTLavavej
changed the title
<format>: The width of output is miscalculated when formatting a floating-point number in the locale-specific form<format>: The width of output is miscalculated when formatting a floating-point number in the locale-specific form
Jan 28, 2024
Describe the bug
Revealed by libc++ test
std/utilities/format/format.functions/locale-specific_form.pass.cpp
.When formatting a floating-point number, digit separators are not taken into account when computing the width of output, which may cause too many fill characters in the output.
For integers, digit separators are correctly handled:
STL/stl/inc/format
Lines 2873 to 2878 in 3eac329
For floating-point numbers, it seems that the width is not adjusted:
STL/stl/inc/format
Lines 3099 to 3102 in 3eac329
Command-line test case
Expected behavior
The output should be
@@12,345
instead of@@@12,345
.STL version
The text was updated successfully, but these errors were encountered: