Botan

Integer Rounding Functions

License
Botan is released under the Simplified BSD License (see LICENSE.md)

T  roundUp(T)(T n, T align_to);

Round up

Parameters
T n an integer
T align_to the alignment boundary
Returns
n rounded up to a multiple of align_to

T  roundDown(T)(T n, T align_to);

Round down

Parameters
T n an integer
T align_to the alignment boundary
Returns
n rounded down to a multiple of align_to

size_t  clamp(size_t n, size_t lower_bound, size_t upper_bound);

Clamp