summaryrefslogtreecommitdiff
path: root/libs/pwyazh/numeric.h
diff options
context:
space:
mode:
authorpryazha <pryadeiniv@mail.ru>2025-01-19 17:33:44 +0500
committerpryazha <pryadeiniv@mail.ru>2025-01-19 17:33:44 +0500
commitbd49bd525f4c6c6c15c4142bf42d1dd38be6fc16 (patch)
tree9e69f473c34b53e9e57d8af1873c39698bf5c80e /libs/pwyazh/numeric.h
initial commit
Diffstat (limited to 'libs/pwyazh/numeric.h')
-rw-r--r--libs/pwyazh/numeric.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/libs/pwyazh/numeric.h b/libs/pwyazh/numeric.h
new file mode 100644
index 0000000..b117084
--- /dev/null
+++ b/libs/pwyazh/numeric.h
@@ -0,0 +1,74 @@
+#ifndef NUMERIC_H
+#define NUMERIC_H
+
+/* NOTE(pryazha): Numeric functions */
+
+#include <math.h>
+
+F32
+f32_abs(F32 value)
+{
+ union {
+ F32 f;
+ U32 u;
+ } result;
+ result.f = value;
+ result.u &= 0x7fffffff;
+ return(result.f);
+}
+
+F64
+f64_abs(F64 value)
+{
+ union {
+ F64 f;
+ U64 u;
+ } result;
+ result.f = value;
+ result.u &= 0x7fffffffffffffff;
+ return(result.f);
+}
+
+F32
+f32_sqrt(F32 value)
+{
+ F32 result = sqrtf(value);
+ return(result);
+}
+
+F32
+f32_sin(F32 value)
+{
+ F32 result = sinf(value);
+ return(result);
+}
+
+F32
+f32_cos(F32 value)
+{
+ F32 result = cosf(value);
+ return(result);
+}
+
+F32
+f32_acos(F32 value)
+{
+ F32 result = acosf(value);
+ return(result);
+}
+
+F32
+f32_tan(F32 value)
+{
+ F32 result = tanf(value);
+ return(result);
+}
+
+F32
+f32_atan(F32 value)
+{
+ F32 result = atanf(value);
+ return(result);
+}
+
+#endif /* NUMERIC_H */