#11435 [Com]: Floats are not handled correctly by printf?
| From: | blow-job652 at hotmail dot com | Date: | Tue, 20 Jul 2004 15:06:38 +0000 |
| Subject: | #11435 [Com]: Floats are not handled correctly by printf? | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-63110@lists.php.net to get a copy of this message | ||
ID: 11435
Comment by: blow-job652 at hotmail dot com
Reported By: tem at iocus dot com
Status: Bogus
Bug Type: Variables related
Operating System: Linux (Mandrake & Redhat)
PHP Version: 4.0 Latest CVS (2001-06-12)
New Comment:
<a href=http://successshavedlatexb.da.ru>blow
job</a>
Previous Comments:
------------------------------------------------------------------------
[2001-06-12 13:23:10] sniper@php.net
The famous rounding issue.
By using 'f' (float) would give you correct result.
Not a bug.
--Jani
------------------------------------------------------------------------
[2001-06-12 09:23:30] tem at iocus dot com
<?php
$test="2.03";
$amount=($test*100);
echo $amount . "\n";
printf("%06d\n",$amount);
$amount=(2.03*100);
printf("%06d\n",$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.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=11435&edit=1