note 83230 added to function.log
| From: | dingus_76 at hotmail dot com | Date: | Fri, 16 May 2008 02:41:45 +0000 |
| Subject: | note 83230 added to function.log | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139431@lists.php.net to get a copy of this message | ||
well i been pulling my hair out trying to get log to work with big numbers and i ended up writing a
bclog function so to save everyone else the stress here it is
<?php
function bclog($X,$base=10,$decimalplace=12){
$integer_value=0;
while($X < 1){
$integer_value = $integer_value - 1 ;
$X = bcmul($X , base);
}
while($X >= $base){
$integer_value = $integer_value + 1;
$X = bcdiv($X , $base );
}
$decimal_fraction = 0.0;
$partial = 1.0;
# Replace X with X to the 10th power
$X = bcpow($X , 10);
while($decimalplace > 0){
$partial = bcdiv($partial , 10);
$digit=0;
while($X >= $base){
$digit = $digit + 1;
$X = bcdiv($X , $base);
}
$decimal_fraction = bcadd($decimal_fraction , bcmul($digit , $partial));
# Replace X with X to the 10th power
$X = bcpow($X , 10);
$decimalplace = $decimalplace - 1 ;
}
return $integer_value + $decimal_fraction ;
}
?>
----
Server IP: 117.104.160.194
Probable Submitter: 61.68.28.47
----
Manual Page -- http://www.php.net/manual/en/function.log.php
Edit -- https://master.php.net/note/edit/83230
Del: integrated -- https://master.php.net/note/delete/83230/integrated
Del: useless -- https://master.php.net/note/delete/83230/useless
Del: bad code -- https://master.php.net/note/delete/83230/bad+code
Del: spam -- https://master.php.net/note/delete/83230/spam
Del: non-english -- https://master.php.net/note/delete/83230/non-english
Del: in docs -- https://master.php.net/note/delete/83230/in+docs
Del: other reasons-- https://master.php.net/note/delete/83230
Reject -- https://master.php.net/note/reject/83230
Search -- https://master.php.net/manage/user-notes.php