mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 08:38:38 +08:00
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
1 changed files with 17 additions and 1 deletions
|
@ -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 a new issue