Introduce a generic clamp function to clean up some similarly duplicated code.

This commit is contained in:
Lioncash
2014-02-04 20:43:07 -05:00
parent 59e2179172
commit 6b87a0ef20
10 changed files with 43 additions and 61 deletions

View File

@ -13,6 +13,15 @@
namespace MathUtil
{
template<class T>
inline void Clamp(T& val, const T& min, const T& max)
{
if (val < min)
val = min;
else if (val > max)
val = max;
}
static const u64 DOUBLE_SIGN = 0x8000000000000000ULL,
DOUBLE_EXP = 0x7FF0000000000000ULL,