|
EllAlgo 1.6.13
|
Functions | |
| template<typename N > | |
| auto | half_nonnegative (N n) noexcept -> typename std::enable_if_t< std::is_integral< N >::value, N > |
| Compute half of a non-negative integral number. | |
|
noexcept |
Compute half of a non-negative integral number.
This function computes half of a non-negative integral number. For integral types, it uses unsigned arithmetic to avoid overflow when dealing with negative numbers.
\[ \lfloor n/2 \rfloor \]
| N | The integral type |
| [in] | n | The non-negative number to halve |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
\[ \lfloor n/2 \rfloor \]