mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 08:38:38 +08:00
nuttx/libm: fix powl wrong if first parameter is negative
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
parent
6b3f51986d
commit
776035ee9e
1 changed files with 17 additions and 1 deletions
|
@ -41,6 +41,22 @@
|
|||
#ifdef CONFIG_HAVE_LONG_DOUBLE
|
||||
long double powl(long double b, long double e)
|
||||
{
|
||||
return expl(e * logl(b));
|
||||
if (b > 0.0)
|
||||
{
|
||||
return expl(e * logl(b));
|
||||
}
|
||||
else if (b < 0.0 && e == (int)e)
|
||||
{
|
||||
if ((int)e % 2 == 0)
|
||||
{
|
||||
return expl(e * logl(fabsl(b)));
|
||||
}
|
||||
else
|
||||
{
|
||||
return -expl(e * logl(fabsl(b)));
|
||||
}
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue