aboutsummaryrefslogtreecommitdiff
path: root/src/libc/math.c
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2021-04-19 19:06:28 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2021-04-19 19:06:28 +0200
commitca1e725b0dc9b10997897dd2ac6d44028601d9bb (patch)
tree0eb7bd087a2382d1d1a660ceda1eae01d1b8b3ca /src/libc/math.c
parentf5146ca9c987ed5e6ea69a0c67b7ed03444be30c (diff)
Init sources
Diffstat (limited to 'src/libc/math.c')
-rw-r--r--src/libc/math.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/libc/math.c b/src/libc/math.c
new file mode 100644
index 0000000..80b1d3a
--- /dev/null
+++ b/src/libc/math.c
@@ -0,0 +1,32 @@
+#include "math.h"
+
+int pow(int x,int n){
+ if(n<0)
+ return -1;
+ else if(n==0)
+ return 1;
+ else if(n==1)
+ return x;
+ int ret=x;
+ for(int i=0;i<(n-1);i++)
+ ret*=x;
+ return ret;
+}
+
+int max(int x,int y){
+ if(x>y)
+ return x;
+ return y;
+}
+
+int min(int x,int y){
+ if(x<y)
+ return x;
+ return y;
+}
+
+int abs(int x){
+ if(x<0)
+ return -x;
+ return x;
+} \ No newline at end of file