aboutsummaryrefslogtreecommitdiff
path: root/libs/libc/inc
diff options
context:
space:
mode:
authorMarvin Borner2021-05-24 13:44:05 +0200
committerMarvin Borner2021-05-24 13:44:05 +0200
commit6ee053435d40a844656a0c4b7ab7617d29b5d759 (patch)
treeee7565e953a1e43688fe4857b1c65d364ea7ac09 /libs/libc/inc
parentcf1a6ed2998eb22b112f233d65975c27fa5ced5b (diff)
Added better float support
Diffstat (limited to 'libs/libc/inc')
-rw-r--r--libs/libc/inc/conv.h8
-rw-r--r--libs/libc/inc/def.h4
-rw-r--r--libs/libc/inc/math.h24
3 files changed, 29 insertions, 7 deletions
diff --git a/libs/libc/inc/conv.h b/libs/libc/inc/conv.h
index 95f7d02..8b88526 100644
--- a/libs/libc/inc/conv.h
+++ b/libs/libc/inc/conv.h
@@ -5,11 +5,7 @@
#include <def.h>
-int atoi(const char *str) NONNULL;
-char *htoa(u32 n);
-int htoi(const char *str) NONNULL;
-char *itoa(int n);
-
-char *conv_base(int value, char *result, int base, int is_signed) NONNULL;
+int itoa(int value, char *buffer, int base);
+char *ftoa(f64 value, char *buffer);
#endif
diff --git a/libs/libc/inc/def.h b/libs/libc/inc/def.h
index c9c89fd..3b173dd 100644
--- a/libs/libc/inc/def.h
+++ b/libs/libc/inc/def.h
@@ -19,6 +19,10 @@ typedef unsigned long u32;
typedef signed long long s64;
typedef unsigned long long u64;
+typedef float f32;
+typedef double f64;
+typedef long double f80;
+
/**
* Useful macros
*/
diff --git a/libs/libc/inc/math.h b/libs/libc/inc/math.h
index 82f431f..8affb72 100644
--- a/libs/libc/inc/math.h
+++ b/libs/libc/inc/math.h
@@ -3,6 +3,28 @@
#ifndef MATH_H
#define MATH_H
-int pow(int base, int exp);
+#include <def.h>
+
+/**
+ * Pi constants
+ */
+
+#define M_1_PI 0.31830988618379067154
+#define M_2_PI 0.63661977236758134308
+#define M_2_SQRTPI 1.12837916709551257390
+
+#define M_PI 3.14159265358979323846
+#define M_PI_2 1.57079632679489661923
+#define M_PI_4 0.78539816339744830962
+
+f64 pow(f64 base, f64 exp);
+f64 sqrt(f64 num);
+
+f32 sinf(f32 angle);
+f64 sin(f64 angle);
+f32 cosf(f32 angle);
+f64 cos(f64 angle);
+f32 tanf(f32 angle);
+f64 tan(f64 angle);
#endif