note 84362 deleted from function.round by danbrown

From: Date: Sun, 17 May 2009 16:12:03 +0000
Subject: note 84362 deleted from function.round by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154764@lists.php.net to get a copy of this message
Note Submitter: Jeremy ---- 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

« previous php.notes (#154764) next »