Thanks! I got there too. It turns out that $resid is behaving like a
Unfortunately, for various reasons, I can't paste the whole script, but you will get a similar error if you do something like this:
$x = floor(3.00);
$resid = pow(2, $x);
echo dechex($resid);
Even though $x is a whole number and the result of 2$x is a whole number, and the documentation states of pow() "If possible, this function will return an integer," I still get an incorrect value.
I understand that pow() is probably returning a float because $x is a float, but php is supposedly a dynamically typed language and should be able to do the float -> integer conversion with no problem when passing $resid into dechex. Even when you try (int)$resid, it gives you 7 and not 8, which doesn't make a whole lot of sense.
Hopefully, this illustrates my point with fewer words:
$x = 3.01;
echo "x: $x\n";
$x = floor($x);
echo "x: $x\n";
$resid = pow(2, $x);
echo "resid: $resid\n";
echo "(int)resid: ";
echo (int)$resid;
echo "\n";
echo "Result: ";
echo dechex((int)$resid);
echo "\n";
e