note 48782 deleted from function.round by felipe

From: Date: Thu, 03 Jan 2008 01:39:28 +0000
Subject: note 48782 deleted from function.round by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134686@lists.php.net to get a copy of this message
Note Submitter: ranzoategui at bolivia dot com ---- <?php /* * @abstract This function is very useful to round totals with definite decimals. * * @param float $value * @param integer $dec * @return float */ function approx( $value, $dec = 2 ) { $value += 0.0; $unit = floor( $value * pow( 10, $dec + 1 ) ) / 10; $round = round( $unit ); return $round / pow( 10, $dec ); } // Example // $round = approx( 3.14159, 4 ); // This result 3.1416 ?>

« previous php.notes (#134686) next »