# Caculate Exponents

5 replies to this topic

### #1 chrisbcats

chrisbcats
• Members
• Member
• 11 posts

Posted 24 May 2006 - 04:34 PM

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

### #2 micah1701

micah1701
• Members
• 613 posts
• LocationEllington, CT USA

Posted 24 May 2006 - 04:40 PM

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]
"Confidence in the face of risk."

### #3 chrisbcats

chrisbcats
• Members
• Member
• 11 posts

Posted 24 May 2006 - 06:49 PM

wow! that was easy. Thanks!

### #4 chrisbcats

chrisbcats
• Members
• Member
• 11 posts

Posted 25 May 2006 - 03:34 PM

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?

### #5 AndyB

AndyB
• Staff Alumni
• 5,465 posts
• LocationToronto

Posted 25 May 2006 - 03:39 PM

Calculate for the positive exponent and then take the reciprocal.

x^-y = 1/x^y
Legend has it that reading the manual never killed anyone.
My site

### #6 chrisbcats

chrisbcats
• Members
• Member
• 11 posts

Posted 25 May 2006 - 03:55 PM

Thanks!

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users