note 77313 deleted from function.round by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 16:17:21 +0000 |
| Subject: | note 77313 deleted from function.round by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154787@lists.php.net to get a copy of this message | ||
Note Submitter: Secret at secret dot com
----
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)