note 49738 deleted from function.round by danbrown

From: Date: Sun, 17 May 2009 16:23:26 +0000
Subject: note 49738 deleted from function.round by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154816@lists.php.net to get a copy of this message
Note Submitter: ron at korving dot demon dot nl ---- This is a slighty shorter and faster version of ranzoategui's round function: <? function stdround($num, $d=0) { $d = pow(10, $d); return round(floor($num * $d * 10) / 10) / $d; } ?> This function behaves exactly like round(), except for the fact that it doesn't apply a so called bankers' rounding algorithm, but a more classic approach (where a 5 is always rounded up). For more info on Banker's rounding: http://en.wikipedia.org/wiki/Significance_arithmetic

« previous php.notes (#154816) next »