#18682 [Csd->Opn]: for loop with floats causes roundup problem
| From: | nohn@php.net | Date: | Thu, 01 Aug 2002 18:13:27 +0000 |
| Subject: | #18682 [Csd->Opn]: for loop with floats causes roundup problem | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-15757@lists.php.net to get a copy of this message | ||
ID: 18682
Updated by: nohn@php.net
Reported By: webmaster@hackquest.com
-Status: Closed
+Status: Open
Bug Type: Variables related
-Operating System: Linux
+Operating System: Linux, Tru64
-PHP Version: 4.2.2
+PHP Version: 4.2.2, 4.3.0-dev
New Comment:
Reopened this bug. My understanding of this that it counts to
(inclusive) 0.:
Extendet the script like this:
<?php
for ($i = 1.0; $i >= 0; $i -= 0.05)
{
print "my i value is '$i'\n";
}
print "end of script\n";
for ($i = 10; $i >= 0; $i -= 1)
{
print "my i value is '$i'\n";
}
print "end of script\n";
?>
the result is:
bndiap56> php4-200207301200_install_alpha_tru64/bin/php
php-bugs/18682.php
Unaligned access pid=146367 <php> va=0x14005e3ec pc=0x1201c6910
ra=0x1201c6904 inst=0xb4010000
my i value is '1'
my i value is '0.95'
my i value is '0.9'
my i value is '0.85'
my i value is '0.8'
my i value is '0.75'
my i value is '0.7'
my i value is '0.65'
my i value is '0.6'
my i value is '0.55'
my i value is '0.5'
my i value is '0.45'
my i value is '0.4'
my i value is '0.35'
my i value is '0.3'
my i value is '0.25'
my i value is '0.2'
my i value is '0.15'
my i value is '0.1'
my i value is '0.05'
end of script
my i value is '10'
my i value is '9'
my i value is '8'
my i value is '7'
my i value is '6'
my i value is '5'
my i value is '4'
my i value is '3'
my i value is '2'
my i value is '1'
my i value is '0'
end of script
Previous Comments:
------------------------------------------------------------------------
[2002-07-31 17:51:59] kalowsky@php.net
Works for me on OSX just fine:
for ($i = 1.0; $i >= 0; $i -= 0.05)
{
print "my i value is '$i'\n";
}
print "end of script\n";
please post a full sample script if this continues.
------------------------------------------------------------------------
[2002-07-31 16:36:34] webmaster@hackquest.com
for ($i = 1.0; $i >= 0; $i -= 0.05)
Will produce the line:
..
..
0.1
0.05
The 0 is missing, obviously its rounded to below zero somehow, and then
gets discarded.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=18682&edit=1