From 23d10fcd25d9fa35a7debf528be841b875ead656 Mon Sep 17 00:00:00 2001 From: EnderIce2 Date: Thu, 7 Mar 2024 21:54:00 +0200 Subject: [PATCH] Add pow and fabs to cmath --- include_std/cmath | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/include_std/cmath b/include_std/cmath index 18668ed..abde42e 100644 --- a/include_std/cmath +++ b/include_std/cmath @@ -34,4 +34,49 @@ namespace std return result; } + + float powf(float base, float exp) + { + float result = 1.0; + for (int i = 0; i < (int)exp; ++i) + result *= base; + return result; + } + + double pow(double base, double exp) + { + double result = 1.0; + for (int i = 0; i < (int)exp; ++i) + result *= base; + return result; + } + + long double powl(long double base, long double exp) + { + long double result = 1.0; + for (long i = 0; i < (long)exp; ++i) + result *= base; + return result; + } + + float fabsf(float num) + { + if (num < 0) + return -num; + return num; + } + + double fabs(double num) + { + if (num < 0) + return -num; + return num; + } + + long double fabsl(long double num) + { + if (num < 0) + return -num; + return num; + } }