php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20692 incrementing in for loop
Submitted: 2002-11-28 02:44 UTC Modified: 2002-11-28 03:40 UTC
From: kuba at 3net dot pl Assigned:
Status: Not a bug Package: Output Control
PHP Version: 4.2.3 OS: RH Linux 7.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
29 + 50 = ?
Subscribe to this entry?

 
 [2002-11-28 02:44 UTC] kuba at 3net dot pl
there is a problem with for loop
code:

$a=1;
$b=1.5;
$step=0.1;

for ($i=$a;$i<=$b;$i=$i+$step) {
  echo "$i<BR>";
}



prints:
1
1.1
1.2
1.3
1.4


and 1.5 value is skipped
when changing this values
to $a=10;$b=15;$step=1;
everything is OK (15 is printed)
so I guess problem is with floating point values




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-28 03:40 UTC] derick@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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 22:01:28 2024 UTC