Merge branch 'master' into cpp-11

This commit is contained in:
Jonathan G Rennison
2019-02-04 18:09:36 +00:00
309 changed files with 13187 additions and 4835 deletions

View File

@@ -370,6 +370,23 @@ static inline int RoundDivSU(int a, uint b)
}
}
/**
* Computes (a / b) rounded away from zero.
* @param a Numerator
* @param b Denominator
* @return Quotient, rounded away from zero
*/
static inline int DivAwayFromZero(int a, uint b)
{
const int _b = static_cast<int>(b);
if (a > 0) {
return (a + _b - 1) / _b;
} else {
/* Note: Behaviour of negative numerator division is truncation toward zero. */
return (a - _b + 1) / _b;
}
}
uint32 IntSqrt(uint32 num);
#endif /* MATH_FUNC_HPP */