From 05498860e8f7b1e8bb27880bc7526de026694804 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 26 Mar 2021 21:55:50 +0100 Subject: Renamed libs Cleaner and more flexible. --- libs/libc/math.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 libs/libc/math.c (limited to 'libs/libc/math.c') diff --git a/libs/libc/math.c b/libs/libc/math.c new file mode 100644 index 0000000..c8142b5 --- /dev/null +++ b/libs/libc/math.c @@ -0,0 +1,17 @@ +// MIT License, Copyright (c) 2020 Marvin Borner + +#include + +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; +} -- cgit v1.2.3