note 107756 added to function.round

From: Date: Fri, 02 Mar 2012 02:14:17 +0000
Subject: note 107756 added to function.round
Groups: php.notes 
Request: Send a blank email to php-notes+get-186460@lists.php.net to get a copy of this message
In order to NOT round up/down the "precision", better use this function ; <?php function dont_touch_the_precision($val, $pre = 0) { return (int) ($val * pow(10, $pre)) / pow(10, $pre); } echo round(0.164654651, 3); // 0.165 echo "\n"; echo dont_touch_the_precision(0.164654651, 3); // 0.164 ?> ---- Server IP: 69.147.83.197 Probable Submitter: 74.210.235.31 ---- Manual Page -- http://www.php.net/manual/en/function.round.php Edit -- https://master.php.net/note/edit/107756 Del: integrated -- https://master.php.net/note/delete/107756/integrated Del: useless -- https://master.php.net/note/delete/107756/useless Del: bad code -- https://master.php.net/note/delete/107756/bad+code Del: spam -- https://master.php.net/note/delete/107756/spam Del: non-english -- https://master.php.net/note/delete/107756/non-english Del: in docs -- https://master.php.net/note/delete/107756/in+docs Del: other reasons-- https://master.php.net/note/delete/107756 Reject -- https://master.php.net/note/reject/107756 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#186460) next »