mirror of
https://github.com/WerWolv/ImHex-Patterns.git
synced 2026-03-28 07:47:02 -05:00
includes/std: Fixed min/max/clamp functions
This commit is contained in:
@@ -3,20 +3,33 @@
|
||||
namespace std::math {
|
||||
|
||||
fn min(auto a, auto b) {
|
||||
return a < b ? a : b;
|
||||
if (a < b)
|
||||
return a;
|
||||
else
|
||||
return b;
|
||||
};
|
||||
|
||||
fn max(auto a, auto b) {
|
||||
return a > b ? a : b;
|
||||
if (a > b)
|
||||
return a;
|
||||
else
|
||||
return b;
|
||||
};
|
||||
|
||||
fn clamp(auto x, auto min, auto max) {
|
||||
return (x < min) ? min : ((x > max) ? max : x);
|
||||
if (x < min)
|
||||
return min;
|
||||
else if (x > max)
|
||||
return max;
|
||||
else
|
||||
return x;
|
||||
};
|
||||
|
||||
fn abs(auto x) {
|
||||
if (x < 0) return -x;
|
||||
else return x;
|
||||
if (x < 0)
|
||||
return -x;
|
||||
else
|
||||
return x;
|
||||
};
|
||||
|
||||
fn sign(auto x) {
|
||||
@@ -93,4 +106,4 @@ namespace std::math {
|
||||
fn acosh(auto value) { return builtin::std::math::acosh(value); };
|
||||
fn atanh(auto value) { return builtin::std::math::atanh(value); };
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user