summaryrefslogtreecommitdiff
path: root/libs/pwyazh/numeric.h
diff options
context:
space:
mode:
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 */