summaryrefslogtreecommitdiff
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.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/common/math_util.h b/src/common/math_util.h
index 9167d2012..b32e7bb14 100644
--- a/src/common/math_util.h
+++ b/src/common/math_util.h
@@ -2,17 +2,22 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-
-#ifndef _MATH_UTIL_H_
-#define _MATH_UTIL_H_
+#pragma once
#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,
@@ -196,5 +201,3 @@ public:
float data[16];
};
-
-#endif // _MATH_UTIL_H_