summaryrefslogtreecommitdiff
path: root/libk/src/math/fclamp.c
diff options
context:
space:
mode:
Diffstat (limited to 'libk/src/math/fclamp.c')
-rw-r--r--libk/src/math/fclamp.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libk/src/math/fclamp.c b/libk/src/math/fclamp.c
new file mode 100644
index 0000000..f757b48
--- /dev/null
+++ b/libk/src/math/fclamp.c
@@ -0,0 +1,13 @@
+#include <math.h>
+
+double fclamp(double x, double l, double h) {
+ if (x < l) return l;
+ if (x > h) return h;
+ return x;
+}
+
+float fclampf(float x, float l, float h) {
+ if (x < l) return l;
+ if (x > h) return h;
+ return x;
+}