nuttx/libm: Fix powf wrong if first parameter is negative
Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
This commit is contained in:
parent
347154c01e
commit
7cd38dca6a
|
@ -37,5 +37,21 @@
|
|||
|
||||
float powf(float b, float e)
|
||||
{
|
||||
return expf(e * logf(b));
|
||||
if (b > 0.0)
|
||||
{
|
||||
return expf(e * logf(b));
|
||||
}
|
||||
else if (b < 0.0 && e == (int)e)
|
||||
{
|
||||
if ((int)e % 2 == 0)
|
||||
{
|
||||
return expf(e * logf(fabsf(b)));
|
||||
}
|
||||
else
|
||||
{
|
||||
return -expf(e * logf(fabsf(b)));
|
||||
}
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue