diff options
author | Marvin Borner | 2020-07-23 13:10:22 +0200 |
---|---|---|
committer | Marvin Borner | 2020-07-23 13:10:22 +0200 |
commit | 99e183a2f569729d722d83503cb851d6198fc1fe (patch) | |
tree | 21e48da4f0220022d17b420de0bf771a97985293 /src/lib/math.c | |
parent | fa00718c221b64070067bcd64acbc297e4ac699c (diff) |
Some functions for stdlib
Diffstat (limited to 'src/lib/math.c')
-rw-r--r-- | src/lib/math.c | 15 |
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; +} |