note 84362 added to function.round

From: Date: Thu, 10 Jul 2008 13:10:30 +0000
Subject: note 84362 added to function.round
Groups: php.notes 
Request: Send a blank email to php-notes+get-141362@lists.php.net to get a copy of this message
Ahh. Found another bug in my bankers_round function. This time it comes when the string is too short (ie 1 character). To adjust this, instead of type casting $x, I am using number_format and giving it an arbitrary precision of 13 digits. (Why 13? Why not!) Old <?php $p = $precision + 1; $x_str = (string)$x; ?> New <?php $p = $precision + 1; $x_str = number_format($x, 13, '.', ''); ?> Jeremy ---- Server IP: 66.207.199.35 Probable Submitter: 72.138.230.145 ---- Manual Page -- http://www.php.net/manual/en/function.round.php Edit -- https://master.php.net/note/edit/84362 Del: integrated -- https://master.php.net/note/delete/84362/integrated Del: useless -- https://master.php.net/note/delete/84362/useless Del: bad code -- https://master.php.net/note/delete/84362/bad+code Del: spam -- https://master.php.net/note/delete/84362/spam Del: non-english -- https://master.php.net/note/delete/84362/non-english Del: in docs -- https://master.php.net/note/delete/84362/in+docs Del: other reasons-- https://master.php.net/note/delete/84362 Reject -- https://master.php.net/note/reject/84362 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#141362) next »