summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTazyFoundSoup <gardendistrict0x0@outlook.com>2026-04-02 21:07:19 +1100
committerTazyFoundSoup <gardendistrict0x0@outlook.com>2026-04-02 21:07:19 +1100
commitc62be285b0891ad0038a2dcddd1a38b78318d2da (patch)
tree814f2bfa20fd307520b16abcdc99a27db4a73473 /include
parent8ea1a6dffc327d2f68a50e00aebd58000181853f (diff)
feat(math): add math core and replace FF_ABS macro with ff_absi
Diffstat (limited to 'include')
-rw-r--r--include/tinyff/math/core.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/include/tinyff/math/core.h b/include/tinyff/math/core.h
new file mode 100644
index 0000000..1db7a40
--- /dev/null
+++ b/include/tinyff/math/core.h
@@ -0,0 +1,50 @@
+#ifndef FF_MATH_H
+#define FF_MATH_H
+
+// NOTE: I'm not going to use macros until I feel like my trash code
+// might actually be used in prod. For now im using my beloved
+// static inline functions. Oh god dennis richie, i love you so bad <3
+
+
+
+static inline int ff_maxi(int a, int b)
+{
+ return a > b ? a : b;
+}
+
+static inline float ff_maxf(float a, float b)
+{
+ return a > b ? a : b;
+}
+
+static inline int ff_mini(int a, int b)
+{
+ return a < b ? a : b;
+}
+
+static inline float ff_minf(float a, float b)
+{
+ return a < b ? a : b;
+}
+
+static inline int ff_clampi(int x, int low, int high)
+{
+ return ff_maxi(low, ff_mini(x, high));
+}
+
+static inline float ff_clampf(float x, float low, float high)
+{
+ return ff_maxf(low, ff_minf(x, high));
+}
+
+static inline int ff_absi(int x)
+{
+ return x < 0 ? -x : x;
+}
+
+static inline float ff_absf(float x)
+{
+ return x < 0 ? -x : x;
+}
+
+#endif \ No newline at end of file