Here’s the surprisingly simple solution to a fairly challenging problem. I do not understand why PHPs GMP extension does not include a gmp_not() function.
function gmp_not($n) {
# convert to binary string
$n = gmp_strval($n, 2);
# invert each bit, one at a time
for($i = 0; $i < strlen($n); $i++) {
$n[$i] = ~$n[$i];
}
# convert back to decimal
return gmp_strval(gmp_init($n, 2), [...]
So far so good on my experimental switch to Ubuntu Linux from Windows XP.
I’m running 64-bit linux because my laptop’s Intel CPU supports it. However, many but not all programs available for linux are available in 64-bit versions. Last few days I’ve needed to install a few programs that don’t have 64-bit versions available, namely, [...]