note 44236 added to function.round
| From: | red at aztec dot sk | Date: | Mon, 19 Jul 2004 09:21:58 +0000 |
| Subject: | note 44236 added to function.round | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-73593@lists.php.net to get a copy of this message | ||
Better is:
<?php
$actual_value = 3.45; // 3.45
$half_round = round(($actual_value*2), 0)/2; // 3.5
?>
or
<?php
$actual_value = 3.45; // 3.45
$temp1 = $actual_value * 2; // 6.9
$temp2 = round($temp1, 0); // 7
$half_round = $temp2 / 2 // 3.5
?>
NOT
<?php
$actual_value = 3.45; // 3.45
$temp1 = $actual_value * 2; // 6.9
$temp2 = round($actual_value, 0); // 7
$half_round = $temp2 / 2 // 3.5
?>
----
Manual Page -- http://www.php.net/manual/en/function.round.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44236
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44236&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44236&report=yes
Search -- http://master.php.net/manage/user-notes.php