#### Archived

This topic is now archived and is closed to further replies.

# Caculate Exponents

## Recommended Posts

How do I caculate exponents (powers) in php?

Here is my formula:

\$netValue = (\$margin_benefit * (1 + \$weightAverage)^((\$improvment/365) - \$margin_benefit));

I need:
[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--](\$margin_benefit * (1 + \$weightAverage) [!--colorc--][/span][!--/colorc--]

to be raised to the

[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]((\$improvment/365) - \$margin_benefit))[!--colorc--][/span][!--/colorc--]

power

##### Share on other sites
I beleive the pow() function should do it.

[a href=\"http://us2.php.net/manual/en/function.pow.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.pow.php[/a]

##### Share on other sites
wow! that was easy. Thanks!

##### Share on other sites
k, that works. Here is my new problem:

pow ( base, exp );

PHP cannot handle negative bases.

I have a negative exponent. The function returns 0.

\$netValue = pow(4140000,-3599999.9);

How can I comupte a negative exponent?

##### Share on other sites
Calculate for the positive exponent and then take the reciprocal.

x^-y = 1/x^y

Thanks!