From 99e183a2f569729d722d83503cb851d6198fc1fe Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 23 Jul 2020 13:10:22 +0200 Subject: Some functions for stdlib --- src/lib/math.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/lib/math.c (limited to 'src/lib/math.c') 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; +} -- cgit v1.2.3