Jump to content

Maxinum length of a float


ttpparker

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.