aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/nums.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdlib/nums.h')
-rw-r--r--src/stdlib/nums.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/stdlib/nums.h b/src/stdlib/nums.h
index f3de9dc5..84d87dd5 100644
--- a/src/stdlib/nums.h
+++ b/src/stdlib/nums.h
@@ -32,6 +32,9 @@ CONSTFUNC bool Num$isnan(double n);
double Num$nan(Text_t tag);
CONSTFUNC double Num$mix(double amount, double x, double y);
OptionalNum_t Num$parse(Text_t text);
+MACROLIKE CONSTFUNC bool Num$is_between(const double x, const double low, const double high) {
+ return low <= x && x <= high;
+}
MACROLIKE CONSTFUNC double Num$clamped(double x, double low, double high) {
return (x <= low) ? low : (x >= high ? high : x);
}
@@ -88,6 +91,9 @@ CONSTFUNC bool Num32$isnan(float n);
CONSTFUNC float Num32$mix(float amount, float x, float y);
OptionalNum32_t Num32$parse(Text_t text);
float Num32$nan(Text_t tag);
+MACROLIKE CONSTFUNC bool Num32$is_between(const float x, const float low, const float high) {
+ return low <= x && x <= high;
+}
MACROLIKE CONSTFUNC float Num32$clamped(float x, float low, float high) {
return (x <= low) ? low : (x >= high ? high : x);
}