ttpparker Posted December 2, 2008 Share Posted December 2, 2008 Im trying to work out a "power to" equation (x to the power of y). I am using the following while loop. while($counter < $TermDays) { $Daily2Worker = $Daily2Worker * $TermDays; $counter = $counter + 1; } This runs 1500 times, the script executes fine but when I output the value $Daily2Worker I get "NaN". If i reduce the number of times the loop runs it works fine. Can anyone help or suggest an alternative way of performing a to the power of calculation. Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted December 2, 2008 Share Posted December 2, 2008 Im trying to work out a "power to" equation (x to the power of y). I am using the following while loop.Why not just use the pow() function? This runs 1500 times, the script executes fine but when I output the value $Daily2Worker I get "NaN". If i reduce the number of times the loop runs it works fine. Can anyone help or suggest an alternative way of performing a to the power of calculation. Knowing how you initialise the values of $Daily2Worker and $TermDays might also help identify what your specific issue is with what should be a very simple loop Also, your logic will not give you x to the power of y Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.