Edit report at http://bugs.php.net/bug.php?id=52689&edit=1

 ID:                 52689
 Updated by:         [email protected]
 Reported by:        jakubmatas at gmail dot com
 Summary:            ban number of loops on float number
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            *General Issues
 Operating System:   Linux
 PHP Version:        5.3.3
 Block user comment: N

 New Comment:

Floating point values have a limited precision. Hence a value might 
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly 
printing it without any mathematical operations.

If you would like to know more about "floats" and what IEEE
754 is, read this:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
 
Thank you for your interest in PHP.

.


Previous Comments:
------------------------------------------------------------------------
[2010-08-24 18:46:33] jakubmatas at gmail dot com

Description:
------------
for different float values in loop (while or for) wrong number of loops.
When 

number si bigger then 4.4 in condition, then one more loop is doing.

Test script:
---------------
for ($index = 3.1; $index < 4.0; $index += 0.1) {

   echo $index.'<br />';

}

for ($index = 3.1; $index < 4.4; $index += 0.1) {

   echo $index.'<br />';

}





Expected result:
----------------
number is 4.0

= OUTPUT ==============

3.1

3.2

3.3

3.4

3.5

3.6

3.7

3.8

3.9



end is 3.9



number is 4.4

= OUTPUT ==============

3.1

3.2

3.3

3.4

3.5

3.6

3.7

3.8

3.9

4

4.1

4.2

4.3



end is 4.3

Actual result:
--------------
number is 4.0

= OUTPUT ==============

3.1

3.2

3.3

3.4

3.5

3.6

3.7

3.8

3.9



end is 3.9



number is 4.4

= OUTPUT ==============

3.1

3.2

3.3

3.4

3.5

3.6

3.7

3.8

3.9

4

4.1

4.2

4.3

4.4 < WRONG



end is 4.4 < WRONG


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52689&edit=1

Reply via email to