chrisbcats Posted May 24, 2006 Share Posted May 24, 2006 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 Link to comment https://forums.phpfreaks.com/topic/10363-caculate-exponents/ Share on other sites More sharing options...
micah1701 Posted May 24, 2006 Share Posted May 24, 2006 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] Link to comment https://forums.phpfreaks.com/topic/10363-caculate-exponents/#findComment-38627 Share on other sites More sharing options...
chrisbcats Posted May 24, 2006 Author Share Posted May 24, 2006 wow! that was easy. Thanks! Link to comment https://forums.phpfreaks.com/topic/10363-caculate-exponents/#findComment-38677 Share on other sites More sharing options...
chrisbcats Posted May 25, 2006 Author Share Posted May 25, 2006 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? Link to comment https://forums.phpfreaks.com/topic/10363-caculate-exponents/#findComment-38938 Share on other sites More sharing options...
AndyB Posted May 25, 2006 Share Posted May 25, 2006 Calculate for the positive exponent and then take the reciprocal.x^-y = 1/x^y Link to comment https://forums.phpfreaks.com/topic/10363-caculate-exponents/#findComment-38941 Share on other sites More sharing options...
chrisbcats Posted May 25, 2006 Author Share Posted May 25, 2006 Thanks! Link to comment https://forums.phpfreaks.com/topic/10363-caculate-exponents/#findComment-38947 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.