note 69500 deleted from ref.bc by colder

From: Date: Thu, 07 Sep 2006 23:39:22 +0000
Subject: note 69500 deleted from ref.bc by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-116883@lists.php.net to get a copy of this message
Note Submitter: jrf at NOSPAM dot jokeaday dot net Reason: in docs ---- BEWARE ! The bcmath functions do not abide by the normal rounding rules, but 'cut off' your string at the digit specified by precision. <?php $x = '0.00016132'; print bcadd( $x, 0, 4 ); // add 0 to try and round off the number at 4 digits printf( '%01.4f', round( $x, 4 ) ); // this does work printf( '%01.4f', $x ); // this works too - round() is not needed as (s)printf will round automatically ?> results in: 0.0001 // incorrect 0.0002 // correct 0.0002 // correct

« previous php.notes (#116883) next »