note 47365 added to function.round

From: Date: Sat, 13 Nov 2004 17:16:14 +0000
Subject: note 47365 added to function.round
Groups: php.notes 
Request: Send a blank email to php-notes+get-80466@lists.php.net to get a copy of this message
If you didn't want to use 'ceil()' or 'floor()' as it only rounds to a whole number u could do this: <?php $actual_value = 3.352; $number = 0.01; //how many decimal places you want it to be $temp1 = $actual_value * 2; $temp2 = $temp1 + $number; //'+ $number' if rounding up '- $number' if rounding down $temp3 = $temp2 / 2; $new_value = round($temp3, 2); echo $new_value; // 3.36 ?> ---- Manual Page -- http://www.php.net/manual/en/function.round.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47365 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47365&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47365&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47365&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47365&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47365&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47365&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47365&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#80466) next »