nuttx/libm: switch from integer to double constants in pow

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
Petro Karashchenko
2024-09-29 23:14:35 +02:00
committed by Xiang Xiao
parent 776035ee9e
commit f0cbcb95ff
2 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -41,11 +41,11 @@
#ifdef CONFIG_HAVE_DOUBLE #ifdef CONFIG_HAVE_DOUBLE
double pow(double b, double e) double pow(double b, double e)
{ {
if (b > 0) if (b > 0.0)
{ {
return exp(e * log(b)); return exp(e * log(b));
} }
else if (b < 0 && e == (int)e) else if (b < 0.0 && e == (int)e)
{ {
if ((int)e % 2 == 0) if ((int)e % 2 == 0)
{ {
@@ -57,6 +57,6 @@ double pow(double b, double e)
} }
} }
return 0; return 0.0;
} }
#endif #endif
+3 -3
View File
@@ -37,11 +37,11 @@
float powf(float b, float e) float powf(float b, float e)
{ {
if (b > 0.0) if (b > 0.0f)
{ {
return expf(e * logf(b)); return expf(e * logf(b));
} }
else if (b < 0.0 && e == (int)e) else if (b < 0.0f && e == (int)e)
{ {
if ((int)e % 2 == 0) if ((int)e % 2 == 0)
{ {
@@ -53,5 +53,5 @@ float powf(float b, float e)
} }
} }
return 0.0; return 0.0f;
} }