note 73537 added to function.round
| From: | chafy at alo dot bg | Date: | Wed, 28 Feb 2007 14:13:03 +0000 |
| Subject: | note 73537 added to function.round | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-123948@lists.php.net to get a copy of this message | ||
The function round numbers to a given precision.
function toFixed($number, $round=2)
{
$tempd = $number*pow(10,$round);
$tempd1 = round($tempd);
$number = $tempd1/pow(10,$round);
return $number;
}
echo round(5.555,2); //retunr 5.55 - I don\t know why
echo toFixed(5.555,2); //return 5.56
----
Server IP: 217.75.128.29
Probable Submitter: 195.22.146.189
----
Manual Page -- http://www.php.net/manual/en/function.round.php
Edit -- https://master.php.net/note/edit/73537
Del: integrated -- https://master.php.net/note/delete/73537/integrated
Del: useless -- https://master.php.net/note/delete/73537/useless
Del: bad code -- https://master.php.net/note/delete/73537/bad+code
Del: spam -- https://master.php.net/note/delete/73537/spam
Del: non-english -- https://master.php.net/note/delete/73537/non-english
Del: in docs -- https://master.php.net/note/delete/73537/in+docs
Del: other reasons-- https://master.php.net/note/delete/73537
Reject -- https://master.php.net/note/reject/73537
Search -- https://master.php.net/manage/user-notes.php