{{ message }}
Repository navigation
Conversation
With the L flag, floating-point values are formatted with the locale's
decimal point, but the hexfloat presentation ('a'/'A') always emitted
'.'. Replace it with the locale decimal point when the value is
localized, like the other floating-point presentations do.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

With the
Lflag, floating-point values use the locale's decimal point (as documented in syntax.md: "inserts the locale's digit grouping characters and — for floating-point values — its decimal point"), but the hexfloat presentation ignores it:For comparison,
std::format(loc, "{:La}", 1234.5)with libstdc++ gives1?34ap+10(without the0xprefix, which fmt always emits).The hexfloat branch of
writewrote the buffer produced byformat_hexfloatdirectly. It now writes it throughwrite_paddedand replaces the.withdecimal_point<Char>(loc)when the value is localized, using the sameFMT_USE_LOCALE && specs.localized()condition asdo_write_float. No digit grouping is applied to hex digits, the0xprefix and the sign-aware zero padding from #4972 are unchanged, and non-localized output is byte-for-byte the same.Tests: added
{:La}and{:+012La}cases tolocale_test.localized_doubleand a wide{:La}case tolocale_test.wformatintest/xchar-test.cc, next to the existing tests that use the samenumpunctfacet. They fail on main ("0x1.34ap+10","+0x0001.8p+0",L"0x1.8p+0") and pass with the change. The full ctest suite passes with g++ 13 in C++17 (FMT_PEDANTIC=ON,FMT_WERROR=ON),format-test,xchar-testandnolocale-testpass in C++11, and clang-format 21 reports no changes.