diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-04-07 01:17:02 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-04-07 01:17:02 -0400 |
| commit | f857f38f718fff586e373815a1bcad2701b4d983 (patch) | |
| tree | 29b3e367437099f39f6fc9a4e7d1dd2f177afb59 /src/stdlib/nums.h | |
| parent | fb4e4cef1382a5e37d99ccb8e97fe1d2a8cd7e93 (diff) | |
Add `is_between()` for various types
Diffstat (limited to 'src/stdlib/nums.h')
| -rw-r--r-- | src/stdlib/nums.h | 6 |
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); } |
