? ?
... ( ); , "" "" ?
11- : , ≤1022 ≈ 307 ( 306 , ), ! , , ≤307. ? ( , : / ?)
? , ...
function bclog10($n){
$pos=strpos($n,'.');
if($pos===false){
$dec_frac='.'.substr($n,0,15);$pos=strlen($n);
}else{ $dec_frac='.'.substr(substr($n,0,$pos).substr($n,$pos+1),0,15);
}
return log10((float)$dec_frac)+(float)$pos;
}
, :
function bclogn($n,$base=M_E){//$base should be float: default is e
return bclog10($n)*log(10)/log($base);
}
, , , ; , Windows 10, , PHP.
15 307 , "BigFloat" - , " "! , , , /. , math.stackexchange.com, , .
: ...
function bclog10($n){
$m=array();
preg_match('/^(-)?0*([1-9][0-9]*)?(\.(0*))?([1-9][0-9]*)?([Ee](-)?0*([1-9][0-9]*))?$/',$n,$m);
if(!isset($m[1])){throw new \Exception('Argument: not decimal number string!');}
$sgn=$m[1];if($sgn==='-'){throw new \Exception('Cannot compute: log(<⁺0)!');}
$abs=$m[2];$pos=strlen($abs);
if(isset($m[4])){$fre=$m[4];}else{$fre='';}$neg=strlen($fre);
if(isset($m[5])){$frc=$m[5];}else{$frc='';}
if(isset($m[7])){$esgn=$m[7]==='-'?-1:1;}else{$esgn=1;}
if(isset($m[8])){$eexp=$m[8];}else{$eexp=0;}
if($pos===0){
$dec_frac='.'.substr($frc,0,15);$pos=-1*$neg;
}else{ $dec_frac='.'.substr($abs.$fre.$frc,0,15);
}
return log10((float)$dec_frac)+(float)$pos+($esgn*$eexp);
}