note 87254 rejected from function.round by danbrown

From: Date: Wed, 26 Nov 2008 20:28:22 +0000
Subject: note 87254 rejected from function.round by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-146999@lists.php.net to get a copy of this message
Note Submitter: jeff at dealer-choice dot com ---- darkstream777 at gmx dot net - In evaluating your function I found an instance where your precision support is not entirely accurate: function roundDigits( $value, $precision=0 ) { $precisionFactor = ($precision == 0) ? 1 : pow( 10, $precision ); return round( $value * $precisionFactor ) / $precisionFactor; } $b = 99.9947; echo roundDigits($b,2); //99.99;

« previous php.notes (#146999) next »