#20688 [Opn->Bgs]: Math zero
| From: | alan_k@php.net | Date: | Thu, 28 Nov 2002 05:18:11 +0000 |
| Subject: | #20688 [Opn->Bgs]: Math zero | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-26034@lists.php.net to get a copy of this message | ||
ID: 20688
Updated by: alan_k@php.net
Reported By: xqcheng@mail.xjtu.edu.cn
-Status: Open
+Status: Bogus
Bug Type: Math related
Operating System: windows
PHP Version: 4.2.3
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
there are quite a few bug reports on this.
adding floats can produce unpredicable results
you could try using bcmath or sprintf
$temp=-1.0;
for($i=0;$i<=10;$i++){
$temp=(float) sprintf("%.2f",$temp+0.2);
echo "<br>".$temp;
}
Previous Comments:
------------------------------------------------------------------------
[2002-11-27 19:42:49] xqcheng@mail.xjtu.edu.cn
<?php
$temp=-1.0;
for($i=0;$i<=10;$i++)
{
$temp=$temp+0.2;
echo "<br>".$temp;
}
?>
the output is :
-0.8
-0.6
-0.4
-0.2
-5.55111512313E-017
0.2
0.4
0.6
0.8
1
1.2
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=20688&edit=1