summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2014-08-21 17:31:43 +0200
committerbunnei <bunneidev@gmail.com>2014-08-21 17:31:43 +0200
commit59d512484a23765784d8c890c4788a8c31fb4c9b (patch)
treef6f9240942a20eefb849e4129b059b413e1bae5d /src/common
parentMerge pull request #64 from linkmauve/master (diff)
parentCommon: Add a clamp function to math_utils.h (diff)
downloadyuzu-59d512484a23765784d8c890c4788a8c31fb4c9b.tar
yuzu-59d512484a23765784d8c890c4788a8c31fb4c9b.tar.gz
yuzu-59d512484a23765784d8c890c4788a8c31fb4c9b.tar.bz2
yuzu-59d512484a23765784d8c890c4788a8c31fb4c9b.tar.lz
yuzu-59d512484a23765784d8c890c4788a8c31fb4c9b.tar.xz
yuzu-59d512484a23765784d8c890c4788a8c31fb4c9b.tar.zst
yuzu-59d512484a23765784d8c890c4788a8c31fb4c9b.zip
Diffstat (limited to 'src/common')
-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 65220fbdf..b32e7bb14 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,