In the following code:
using seconds = std::chrono::duration<long double, std::ratio<1, 1>>;
using namespace std::literals;
int main() {
seconds s = 10ms + 10us + 10ns;
std::print("from chrono {} | from count {:%Q}\n", s, s);
}
I get the print out:
from chrono 0.01001s | from count 0.01001001
Why is the format for chrono passed directly in cropping the time this way? The chrono duration can represent the nanoseconds and clearly the format specification allows printing decimals. Why does it stop after 5 decimal places?
If i change it to:
seconds s = 10ms + 10us + 123ns;
std::print("from chrono {} | from count {:%Q}\n", s, s);
Then i get
from chrono 0.0100101s | from count 0.010010123
Which has more precision but is still wrong. There does not appear to be a format specifier that affects this (format specialisation).
What is the explanation for this behaviour?
double? If i print a double the same way (aka count) it gives me the correct precision.