View Single Post
Old 05-20-2008, 12:08 AM   #6 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

OK, looks like there may be a rounding problem on your machine or version of PHP (mine's 5.2.5). Simply round the value rather than casting it to integer.

$rounds = round(log($players, 2)); // 6

As a fun check try: echo (int) 5.999999999999999; that's what PHP might be seeing rather than 6 as we expect.
Salathe is offline  
Reply With Quote