diff options
author | axtlos <axtlos@disroot.org> | 2024-09-23 23:01:51 +0200 |
---|---|---|
committer | axtlos <axtlos@disroot.org> | 2024-09-23 23:01:51 +0200 |
commit | 8996ee7580ed85b42b6399f9f64e29092ce21c41 (patch) | |
tree | 3cec945364e91e6504edf9a6c533fa104a0d3f34 /src/extlib.c | |
parent | d9aeb51683449ef79339c9ca3c80059c17dec599 (diff) | |
download | extlib-8996ee7580ed85b42b6399f9f64e29092ce21c41.tar.gz extlib-8996ee7580ed85b42b6399f9f64e29092ce21c41.tar.bz2 |
Add cap,min,max functions
Diffstat (limited to 'src/extlib.c')
-rw-r--r-- | src/extlib.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/extlib.c b/src/extlib.c index e1fdb14..108e3e5 100644 --- a/src/extlib.c +++ b/src/extlib.c @@ -96,3 +96,21 @@ rrmdir (char *pathname) return err; return 0; } + +inline float +min (float v, float min_v) +{ + return (v < min_v) ? min_v : v; +} + +inline float +max (float v, float max_v) +{ + return (v > max_v) ? max_v : v; +} + +inline float +cap (float v, float min_v, float max_v) +{ + return min(max(v, max_v), min_v); +} |