In PHP, the pow() function is used for calculating powers. "pow(a, b)" returns a^b. Then there's another function called rand(), which can be used for generating random numbers. "rand(1, 100)" returns a random number between 1 and 100.
What do these functions have in common? I don't know. Apparently though, on the new server, once a random number is generated, the next pow() function will always return 0. Mind = blown.
Example:
<?phpSo really, the delay is not my fault! I submitted a ticket to NameCheap 5 minutes ago, we'll see what they make of it.
echo pow(1.1, 50); // Prints: 117.39085288
echo pow(1.1, 50); // Prints: 117.39085288
// etc...
$rand = rand(1, 100);
echo pow(1.1, 50); // Prints: 0
echo pow(1.1, 50); // Prints: 117.39085288
echo pow(1.1, 50); // Prints: 117.39085288
// etc...
?>
Bayo~
For a temporary fix, couldn't you just make pow() run once after every rand()?
ReplyDeletecurb, that sounds like a programming hack, and its bad news for anything long term
ReplyDeleteI was thinking of it as purely a short-term fix. Definitely not something that would stay there forever.
ReplyDeleteHah, that's not a bad idea. Wouldn't want any other mathematical bugs though. And frankly, if there's one bug, I always fear there are more. It might have effect on different functions too.
ReplyDeleteThe hosting company replied and agreed it was a strange bug. It's only reproducible on the server we're on, and all the other servers are working with the exact PHP version. Anyway, they're moving us to a new server now.