This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
Section: 28.2.2 [charconv.to.chars] Status: New Submitter: Victor Zverovich Opened: 2026-07-04 Last modified: 2026-07-04
Priority: Not Prioritized
View other active issues in [charconv.to.chars].
View all other issues in [charconv.to.chars].
View all issues with New status.
Discussion:
P3505R4 (See also isocpp.org/P3505R4)
unintentionally changed the semantics of the thresholds used to select between f and e formatting
for the default floating-point representation.
The conversion specifier is
fif the absolute value of value is in the range[m, n), wheremis the nearest representable asTvalue of10-4andnis the nearest representable asTvalue ofstd::numeric_limits<T>::radixstd::numeric_limits<T>::digits + 1rounded down to the nearest power of10,eotherwise
However, P3505R4, approved in Brno, changed this to:
The conversion specifier is
fif the absolute value of value is in the range[l, u), wherelis the smallest value larger or equal to10-4that is representable byTanduis the largest value smaller or equal tostd::numeric_limits<T>::radixstd::numeric_limits<T>::digits + 1rounded down to the nearest power of10representable byT, otherwisee.
This changes observable behavior. For example, on IEEE-754 implementations, the nearest
representable float value to 10-4 is slightly smaller than 10-4.
Under the wording in P3505R3 it is formatted using f, while under the wording
in P3505R4 it is formatted using e.
std::format("{}", 0.0001f);
produces "0.0001" under the original wording, but "1e-4" under the current wording.
Proposed resolution:
This wording is relative to N5046 plus the wording changes applied by P3505R4 (isocpp.org/P3505R4) approved at the 2026 Brno meeting.
Modify 28.2.2 [charconv.to.chars] as indicated:
to_chars_result to_chars(char* first, char* last, floating-point-type value);-7- Effects: Let
The conversion specifier isTbefloating-point-type.valueis converted to a string in the style ofprintfin the "C" locale.fif the absolute value of value is in the range[l, u), wherelis thesmallest value larger or equal tonearest representable as10-4that is representable byTTvalue of10-4anduis thelargest value smaller or equal tonearest representable asstd::numeric_limits<T>::radixstd::numeric_limits<T>::digits + 1rounded down to the nearest power of10representable byTTvalue ofstd::numeric_limits<T>::radixstd::numeric_limits<T>::digits + 1rounded down to the nearest power of 10, otherwisee. -8- Throws: Nothing.