aboutsummaryrefslogtreecommitdiff
path: root/util/integer_division_unittest.cc
AgeCommit message (Collapse)Author
2019-07-18Add integer math utilities for Cast StreamingYuri Wiitala
This adds utilities for doing some common integer operations in the upcoming math-heavy Cast Streaming patches, and cleans-up some of the existing code to use them: 1. saturated_cast<>: Casts a larger-sized integer type to a smaller- sized one, clamping the values to the valid range of the smaller type. 2. Integer division with rounding: CEIL(a ÷ b) and ROUND_NEAREST(a ÷ b). The templates were defined such that this also works with the std::chrono duration types. Change-Id: I995b9363d15e290e8d11ae2ed85918dd95ab6574 Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/1705521 Reviewed-by: Yuri Wiitala <miu@chromium.org> Reviewed-by: Max Yakimakha <yakimakha@chromium.org> Commit-Queue: Yuri Wiitala <miu@chromium.org>