Bug #11435 Updated: Floats are not handled correctly by printf?

From: Date: Tue, 12 Jun 2001 17:23:11 +0000
Subject: Bug #11435 Updated: Floats are not handled correctly by printf?
Groups: php.dev 
Request: Send a blank email to php-dev+get-57001@lists.php.net to get a copy of this message
ID: 11435 Updated by: sniper Reported By: tem@iocus.com Old-Status: Open Status: Bogus Bug Type: Variables related Operating system: PHP Version: 4.0 Latest CVS (2001-06-12) Assigned To: Comments: The famous rounding issue. By using 'f' (float) would give you correct result. Not a bug. --Jani Previous Comments: --------------------------------------------------------------------------- [2001-06-12 09:23:30] tem@iocus.com <?php $test="2.03"; $amount=($test*100); echo $amount . "n"; printf("%06dn",$amount); $amount=(2.03*100); printf("%06dn",$amount); ?> Produces the following output: 203 000202 000202 My math is a little fuzzy but I think 2.03 * 100 = 203. This used to work in php 3.x but seems to be broken since the 4.x beta. --------------------------------------------------------------------------- ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://bugs.php.net/?id=11435&edit=2

« previous php.dev (#57001) next »