note 78414 added to function.round
| From: | thaweefromthailand at osu1 dot php dot net | Date: | Thu, 11 Oct 2007 04:41:40 +0000 |
| Subject: | note 78414 added to function.round | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131292@lists.php.net to get a copy of this message | ||
my round function
function rounding($n,$d){
$base=intval($n);
$n=number_format($n,25);
$dotpos=strpos($n,".");
$strlen=strlen($n);
$b= substr($n,$dotpos+1,$strlen-$dotpos);
$j=1;
$p=0;
for($i=strlen($b);$i>$d;$i--){
$c=substr($b,-$j,1)+$p;
if($c<5){
$p=0;
}else{
$p=1;
}
$j++;
}
return $base+((substr($b,0,$d)+$p)/pow(10,$d));
}
----
Server IP: 203.121.145.116
Probable Submitter: 203.156.178.233
----
Manual Page -- http://www.php.net/manual/en/function.round.php
Edit -- https://master.php.net/note/edit/78414
Del: integrated -- https://master.php.net/note/delete/78414/integrated
Del: useless -- https://master.php.net/note/delete/78414/useless
Del: bad code -- https://master.php.net/note/delete/78414/bad+code
Del: spam -- https://master.php.net/note/delete/78414/spam
Del: non-english -- https://master.php.net/note/delete/78414/non-english
Del: in docs -- https://master.php.net/note/delete/78414/in+docs
Del: other reasons-- https://master.php.net/note/delete/78414
Reject -- https://master.php.net/note/reject/78414
Search -- https://master.php.net/manage/user-notes.php