Fixed pow() for negative bases.
This commit is contained in:
parent
4cd4303c32
commit
985710665a
|
@ -40,7 +40,23 @@
|
|||
|
||||
#ifdef CONFIG_HAVE_DOUBLE
|
||||
double pow(double b, double e)
|
||||
{
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue