note 86330 deleted from function.round by googleguy

From: Date: Sun, 09 Dec 2012 08:22:34 +0000
Subject: note 86330 deleted from function.round by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-192415@lists.php.net to get a copy of this message
Note Submitter: darkstream777 at gmx dot net ---- Here is another method to round digits with precision support: <?php function roundDigits( $value, $precision=0 ) { $precisionFactor = ($precision == 0) ? 1 : pow( 10, $precision ); return round( $value * $precisionFactor ) / $precisionFactor; } ?> Example: echo roundDigits(1.859438,2) . "<br />"; // equals 1.86 echo roundDigits(1.444444,4); // equals 1.4444 Greetings, darki

« previous php.notes (#192415) next »