aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/common/math_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/math_util.h')
-rw-r--r--src/common/math_util.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/common/math_util.h b/src/common/math_util.h
index 65220fbd..b32e7bb1 100644
--- a/src/common/math_util.h
+++ b/src/common/math_util.h
@@ -6,11 +6,18 @@
#include "common/common.h"
+#include <algorithm>
#include <vector>
namespace MathUtil
{
+template<typename T>
+inline T Clamp(const T val, const T& min, const T& max)
+{
+ return std::max(min, std::min(max, val));
+}
+
static const u64 DOUBLE_SIGN = 0x8000000000000000ULL,
DOUBLE_EXP = 0x7FF0000000000000ULL,
DOUBLE_FRAC = 0x000FFFFFFFFFFFFFULL,