Код: Выделить всё
template
constexpr ToDuration round(const duration& d);
< /blockquote>
Вот мой точный код: < /p>
Код: Выделить всё
#include
#include
#include
#include
int main()
{
std::chrono::duration seconds{std::numeric_limits::max()};
printf("float: %f\n", seconds.count());
printf("uint32_t: %u\n", std::chrono::round(seconds).count());
printf(" int32_t: %d\n", std::chrono::round(seconds).count());
printf("uint64_t: %lu\n", std::chrono::round(seconds).count());
printf(" int64_t: %ld\n", std::chrono::round(seconds).count());
}
< /code>
, который выводит < /p>
float: 340282346638528859811704183484516925440.000000
uint32_t: 1
int32_t: -2147483647
uint64_t: 9223372036854775809
int64_t: -9223372036854775807
< /code>
Как вы можете видеть, другие типы целочисленных целого числа также ведут себя странно. В отличие от std :: lround
Подробнее здесь: https://stackoverflow.com/questions/779 ... s-intended