aboutsummaryrefslogtreecommitdiff
path: root/src/lib/math.c
diff options
context:
space:
mode:
authorMarvin Borner2020-07-23 13:10:22 +0200
committerMarvin Borner2020-07-23 13:10:22 +0200
commit99e183a2f569729d722d83503cb851d6198fc1fe (patch)
tree21e48da4f0220022d17b420de0bf771a97985293 /src/lib/math.c
parentfa00718c221b64070067bcd64acbc297e4ac699c (diff)
Some functions for stdlib
Diffstat (limited to 'src/lib/math.c')
-rw-r--r--src/lib/math.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/math.c b/src/lib/math.c
new file mode 100644
index 0000000..9cd9cea
--- /dev/null
+++ b/src/lib/math.c
@@ -0,0 +1,15 @@
+// MIT License, Copyright (c) 2020 Marvin Borner
+
+int pow(int base, int exp)
+{
+ if (exp < 0)
+ return 0;
+
+ if (!exp)
+ return 1;
+
+ int ret = base;
+ for (int i = 1; i < exp; i++)
+ ret *= base;
+ return ret;
+}