diff --git a/libs/libc/math/lib_pow.c b/libs/libc/math/lib_pow.c index c918479ea3..e82e181eb2 100644 --- a/libs/libc/math/lib_pow.c +++ b/libs/libc/math/lib_pow.c @@ -41,6 +41,22 @@ #ifdef CONFIG_HAVE_DOUBLE double pow(double b, double e) { - return exp(e * log(b)); + if (b > 0) + { + return exp(e * log(b)); + } + else if (b < 0 && e == (int)e) + { + if ((int)e % 2 == 0) + { + return exp(e * log(fabs(b))); + } + else + { + return -exp(e * log(fabs(b))); + } + } + + return 0; } #endif