note 77313 added to function.round
| From: | Secret at secret dot com | Date: | Fri, 24 Aug 2007 05:26:59 +0000 |
| Subject: | note 77313 added to function.round | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129742@lists.php.net to get a copy of this message | ||
Round down..
A very simple way to round down is the following..
$numbera=41;
$numberb=3;
$sum=$numbera/$numberb;
echo $sum; // Will give 13.66666.....
$rounddownsum=(int)($numbera/$numberb);
echo $rounddownsum; // Will give 13 ;o)
If you wana round decimals simply multiply the variables with 10...100...1000 or whatever before
performing this action.. Then divide back after calculations.. then ex.
$numbera=41;
$numberb=3;
$sum=$numbera/$numberb;
$sum=(int)($sum*1000);
$sum=$sum/1000;
echo $sum; // Will give 13.666
Hope that helps someone... ;o)
----
Server IP: 212.63.193.10
Probable Submitter: 81.216.193.184
----
Manual Page -- http://www.php.net/manual/en/function.round.php
Edit -- https://master.php.net/note/edit/77313
Del: integrated -- https://master.php.net/note/delete/77313/integrated
Del: useless -- https://master.php.net/note/delete/77313/useless
Del: bad code -- https://master.php.net/note/delete/77313/bad+code
Del: spam -- https://master.php.net/note/delete/77313/spam
Del: non-english -- https://master.php.net/note/delete/77313/non-english
Del: in docs -- https://master.php.net/note/delete/77313/in+docs
Del: other reasons-- https://master.php.net/note/delete/77313
Reject -- https://master.php.net/note/reject/77313
Search -- https://master.php.net/manage/user-notes.php