Skip to content

Instantly share code, notes, and snippets.

@fwolf
Created October 31, 2013 14:06
Show Gist options
  • Save fwolf/7250392 to your computer and use it in GitHub Desktop.
Save fwolf/7250392 to your computer and use it in GitHub Desktop.
Number equal or larger than 100000000000000(1.0E+14) will represent by Scientific Notation(科学记数法), cause base_convert() loose precision. So for larger number, use BC Math or GMP. This array is used to check number string length per base, if string is longer than the array value, it should not use build-in base_convert(). Un-formatted for run usi…
for ($j = 2; $j < 63; $j ++) {
$x = $j; $i = 1; $y = $x;
while ($y < 100000000000000) {
$i ++;
$y = pow($x, $i);
}
$i --;
$y = pow($x, $i);
echo "$x^$i = $y, length " . strlen($y) . "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment