diff options
| author | 2014-08-21 11:31:43 -0400 | |
|---|---|---|
| committer | 2014-08-21 11:31:43 -0400 | |
| commit | 59d512484a23765784d8c890c4788a8c31fb4c9b (patch) | |
| tree | f6f9240942a20eefb849e4129b059b413e1bae5d /src/common/math_util.h | |
| parent | Merge pull request #64 from linkmauve/master (diff) | |
| parent | Common: Add a clamp function to math_utils.h (diff) | |
| download | yuzu-59d512484a23765784d8c890c4788a8c31fb4c9b.tar.gz yuzu-59d512484a23765784d8c890c4788a8c31fb4c9b.tar.xz yuzu-59d512484a23765784d8c890c4788a8c31fb4c9b.zip | |
Merge pull request #58 from lioncash/clamp
Common: Add a clamp function to math_utils.h
Diffstat (limited to 'src/common/math_util.h')
| -rw-r--r-- | src/common/math_util.h | 7 |
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 @@ | |||
| 6 | 6 | ||
| 7 | #include "common/common.h" | 7 | #include "common/common.h" |
| 8 | 8 | ||
| 9 | #include <algorithm> | ||
| 9 | #include <vector> | 10 | #include <vector> |
| 10 | 11 | ||
| 11 | namespace MathUtil | 12 | namespace MathUtil |
| 12 | { | 13 | { |
| 13 | 14 | ||
| 15 | template<typename T> | ||
| 16 | inline T Clamp(const T val, const T& min, const T& max) | ||
| 17 | { | ||
| 18 | return std::max(min, std::min(max, val)); | ||
| 19 | } | ||
| 20 | |||
| 14 | static const u64 DOUBLE_SIGN = 0x8000000000000000ULL, | 21 | static const u64 DOUBLE_SIGN = 0x8000000000000000ULL, |
| 15 | DOUBLE_EXP = 0x7FF0000000000000ULL, | 22 | DOUBLE_EXP = 0x7FF0000000000000ULL, |
| 16 | DOUBLE_FRAC = 0x000FFFFFFFFFFFFFULL, | 23 | DOUBLE_FRAC = 0x000FFFFFFFFFFFFFULL, |