note 49738 added to function.round
| From: | ronatkorvingdotdemondotnl at osu1 dot php dot net | Date: | Mon, 07 Feb 2005 14:12:31 +0000 |
| Subject: | note 49738 added to function.round | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-84616@lists.php.net to get a copy of this message | ||
This is a slighty shorter and faster version of ranzoategui's round function:
<?
function stdround($num, $d=0)
{
$d = pow(10, $d);
return round(floor($num * $d * 10) / 10) / $d;
}
?>
This function behaves exactly like round(), except for the fact that it doesn't apply a so
called bankers' rounding algorithm, but a more classic approach (where a 5 is always rounded
up).
For more info on Banker's rounding: http://en.wikipedia.org/wiki/Significance_arithmetic
----
Manual Page -- http://www.php.net/manual/en/function.round.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49738
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49738&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49738&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49738&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49738&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49738&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49738&report=yes
Search -- http://master.php.net/manage/user-notes.php