CeilDiv

Description

Returns the quotient rounded upward to the nearest integer.

Prototype

template <typename T>
auto CeilDiv(T x, T y) -> typename std::enable_if<std::is_signed<T>::value, T>::type
template <typename T>
auto CeilDiv(T x, T y) -> typename std::enable_if<std::is_unsigned<T>::value, T>::type

Parameters

Parameter

Input/Output

Description

x

Input

Dividend.

y

Input

Divisor.

Return Value

T: Returns the rounded-up division result. If the divisor is 0, the dividend is returned.

Constraints

The divisor and dividend must be integers of the same type (excluding the bool type).

Example

The following sample code is for reference only. Do not copy and run it.

1
CeilDiv<int32_t>(5000, 4096)