Commit 256cc61a by Abseil Team Committed by Copybara-Service

Enhance documentation about absl::Duration integer division, which

truncates, and floating-point multiplication/division, which rounds.

PiperOrigin-RevId: 517016481
Change-Id: I3b0c357ea7236f2c0231df5e6b47c742c3f40047
parent ab0e3e8e
......@@ -187,7 +187,12 @@ class Duration {
Duration& operator%=(Duration rhs);
// Overloads that forward to either the int64_t or double overloads above.
// Integer operands must be representable as int64_t.
// Integer operands must be representable as int64_t. Integer division is
// truncating, so values less than the resolution will be returned as zero.
// Floating-point multiplication and division is rounding (halfway cases
// rounding away from zero), so values less than the resolution may be
// returned as either the resolution or zero. In particular, `d / 2.0`
// can produce `d` when it is the resolution and "even".
template <typename T, time_internal::EnableIfIntegral<T> = 0>
Duration& operator*=(T r) {
int64_t x = r;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment