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
Any chrono duration n where 0 < n < 10⁻ᴺ formatted with {:.N%S} receives full precision instead of N decimals. This also holds if adding any number of whole seconds. In other words, any duration where the decimal part should have been rounded to .0, .00, .000 etc. will be printed with all decimals. For example, with {:.2%S}, 4567 milliseconds are printed as 04.56, while 4007 milliseconds are printed as 04.007 (instead of the expected 04.00). 4007000 microseconds are printed as 04.007000 while 4017000 microseconds are printed as 04.01.
If the decimal part is exactly zero (i.e., the duration is a whole number of seconds), there will be one zero more than the specified precision. Thus, 1000 milliseconds will be printed as 01.00 with {:.1%S}, 01.000 with {:.2%S} etc., whilst 1100 milliseconds will be printed as 01.1, 01.10 etc. (as expected) for the same format strings.
Many improvemnts. Highlights include:
- Added formatters for `std::chrono::day`, `std::chrono::month`,
`std::chrono::year` and `std::chrono::year_month_day`
- Fixed handling of precision in `%S` (fmtlib/fmt#3794,
- Added a formatter for `std::complex`
- Added a formatter for `std::expected`
- Added a formatter for `std::type_info`
and much faster compile times even without using the new cut down
fmt/base.h which provides the printf() equivalent family of functions.
For a full list see https://github.com/fmtlib/fmt/blob/11.0.1/ChangeLog.md
jperkin
pushed a commit
to pkgsrc-ci/pkgsrc
that referenced
this issue
Jul 16, 2024
Many improvemnts. Highlights include:
- Added formatters for `std::chrono::day`, `std::chrono::month`,
`std::chrono::year` and `std::chrono::year_month_day`
- Fixed handling of precision in `%S` (fmtlib/fmt#3794,
- Added a formatter for `std::complex`
- Added a formatter for `std::expected`
- Added a formatter for `std::type_info`
and much faster compile times even without using the new cut down
fmt/base.h which provides the printf() equivalent family of functions.
For a full list see https://github.com/fmtlib/fmt/blob/11.0.1/ChangeLog.md
Any chrono duration n where 0 < n < 10⁻ᴺ formatted with
{:.N%S}
receives full precision instead of N decimals. This also holds if adding any number of whole seconds. In other words, any duration where the decimal part should have been rounded to.0
,.00
,.000
etc. will be printed with all decimals. For example, with{:.2%S}
, 4567 milliseconds are printed as04.56
, while 4007 milliseconds are printed as04.007
(instead of the expected04.00
). 4007000 microseconds are printed as04.007000
while 4017000 microseconds are printed as04.01
.If the decimal part is exactly zero (i.e., the duration is a whole number of seconds), there will be one zero more than the specified precision. Thus, 1000 milliseconds will be printed as
01.00
with{:.1%S}
,01.000
with{:.2%S}
etc., whilst 1100 milliseconds will be printed as01.1
,01.10
etc. (as expected) for the same format strings.Code to reproduce:
Expected output:
Actual output:
Godbolt:
https://godbolt.org/z/rncqqGWW3
Tested with recent versions of Clang and GCC. Affects both
fmt::format
andfmt::println
.The text was updated successfully, but these errors were encountered: