- gmp_mul: documentation ( source)
- str_split: documentation ( source)
- gmp_pow: documentation ( source)
- gmp_strval: documentation ( source)
<?php
$a = gmp_pow("10", 100);
$b = gmp_pow("10", 303);
$c = gmp_pow("10", 600);
echo "10^100 * 10^600 = ".dumbFormatScientific(gmp_mul($a, $c))." Aka.: \n";
echo gmp_mul($a, $c)."\n";
echo "10^100 * 10^303 = ".dumbFormatScientific(gmp_mul($a, $b))." Aka.: \n";
echo gmp_mul($a, $b)."\n";
function dumbFormatScientific(GMP $input)
{
$string = gmp_strval($input);
$str_arr = str_split($string);
$char_cnt = 0;
foreach($str_arr as $char)
{
if($char == 0)
{
$char_cnt++;
}
}
return "10^".$char_cnt;
}
?>