note 17629 added to function.round

From: Date: Mon, 17 Dec 2001 18:33:42 +0000
Subject: note 17629 added to function.round
Groups: php.notes 
Request: Send a blank email to php-notes+get-22993@lists.php.net to get a copy of this message
Above does only work correct for positive numbers. Below works for both numbers. function alt_round ($number, $decimals) { if (bccomp($number,0) > 0) { return (bcadd (bcadd ($number, "0.".str_repeat("0",$decimals)."5", $decimals+1), 0, $decimals)); } else { return (bcadd (bcsub ($number, "0.".str_repeat("0",$decimals)."5", $decimals+1), 0, $decimals)); } } Enjoy and use at your own risk. - Felix Schwarz, Innovative -- http://www.php.net/manual/en/function.round.php http://master.php.net/manage/user-notes.php?action=edit+17629 http://master.php.net/manage/user-notes.php?action=delete+17629 http://master.php.net/manage/user-notes.php?action=reject+17629

« previous php.notes (#22993) next »