includes/std: Fixed min/max/clamp functions

This commit is contained in:
WerWolv
2022-05-28 14:11:45 +02:00
committed by GitHub
parent 4ec37dea37
commit 68edebbe4f

View File

@@ -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); };
}
}