php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37943 decimal counting error
Submitted: 2006-06-28 09:13 UTC Modified: 2006-06-28 09:17 UTC
From: atbjk at yahoo dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.4.2 OS: windows
Private report: No CVE-ID: None
 [2006-06-28 09:13 UTC] atbjk at yahoo dot com
Description:
------------
there is a prob when adding decimal together, they do not print the trialing zero.

Reproduce code:
---------------
for ($i=0; $i<23; $i++) {
echo 0.0001+($i*0.0001).'<br>';
}

Expected result:
----------------
0.0001
0.0002
0.0003
0.0004
0.0005
0.0006
0.0007
0.0008
0.0009
0.0010
0.0011
0.0012
0.0013
0.0014
0.0015
0.0016
0.0017
0.0018
0.0019
0.0020
0.0021
0.0022
0.0023

Actual result:
--------------
0.0001
0.0002
0.0003
0.0004
0.0005
0.0006
0.0007
0.0008
0.0009
0.001
0.0011
0.0012
0.0013
0.0014
0.0015
0.0016
0.0017
0.0018
0.0019
0.002
0.0021
0.0022
0.0023

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-28 09:17 UTC] tony2001@php.net
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


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Dec 04 13:00:01 2025 UTC