note 79628 added to function.bcscale

From: Date: Thu, 06 Dec 2007 02:45:50 +0000
Subject: note 79628 added to function.bcscale
Groups: php.notes 
Request: Send a blank email to php-notes+get-132870@lists.php.net to get a copy of this message
These functions DO NOT round off your values. No arbitrary precision libraries do it this way. It stops calculating after reaching scale of decimal places, which mean that your value is cut off after scale number of digits, not rounded. To do the rounding use something like this: <?php function bcround($number, $scale=0) { $fix = "5"; for ($i=0;$i<$scale;$i++) $fix="0$fix"; $number = bcadd($number, "0.$fix", $scale+1); return bcdiv($number, "1.0", $scale); } ?> ---- Server IP: 195.136.184.34 Probable Submitter: 82.210.168.141 ---- Manual Page -- http://www.php.net/manual/en/function.bcscale.php Edit -- https://master.php.net/note/edit/79628 Del: integrated -- https://master.php.net/note/delete/79628/integrated Del: useless -- https://master.php.net/note/delete/79628/useless Del: bad code -- https://master.php.net/note/delete/79628/bad+code Del: spam -- https://master.php.net/note/delete/79628/spam Del: non-english -- https://master.php.net/note/delete/79628/non-english Del: in docs -- https://master.php.net/note/delete/79628/in+docs Del: other reasons-- https://master.php.net/note/delete/79628 Reject -- https://master.php.net/note/reject/79628 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132870) next »