The following code is supposed to check to see if an inputed number is a power of 26. On the localhost the comparison evaluates as false when it should be true, but when it is running on the live php server it works as expected.
#there is an html text input
$foo = $_POST['someval'];
if(intval(log($foo, 26)) == floatval(log($foo, 26))) {
echo 'yup, that there number is a power of 26';
}
else {
echo 'nope, definitely not a power of 26';
}
I should note, on the localhost the "if" will SOMETIMES evaluate true. It happens for every other power of 26 (eg. 26 will be true, 676 (26 squared) will be false, 17576 (26 cubed) will be true). However when it is running on the live server, everything works as expected and the "if" evaluates true for every power of 26.
I can not figure out what is causing this discrepancy. The live server is running PHP 5.3.8 I have tried two different local stacks (mamp & ampps) which are running PHP 5.3.6 & 5.3.10 respectively and the same thing occurs on both.
I have also tried writing the code so that the math is done outside of the "if" statement with no luck there either.
This is not a high priority issue since the code works where it is supposed to (live) but it is bugging me that there is a discrepancy. Let me know if you see what is going on or if you have a better way to check if a number is a power of 26.