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
https://forums.phpfreaks.com/topic/135124-maxinum-length-of-a-float/
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

Archived

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

×
×
  • 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.