ID: 50679 Updated by: [email protected] Reported By: kauffj at gmail dot com -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: Ubuntu 9.10 PHP Version: 5.3.1 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-01-06 16:07:12] kauffj at gmail dot com Description: ------------ The range function works on some float values but not others. Reproduce code: --------------- WORKS: print_r(range(0.3, 0.4, 0.1)); FAILS: print_r(range(5.5, 5.6, 0.1)); WORKS: print_r(range(5.5, 5.7, 0.1)); Expected result: ---------------- Array ( [0] => 0.3 [1] => 0.4 ) Array ( [0] => 5.5 [1] => 5.6 ) Array ( [0] => 5.5 [1] => 5.6 [2] => 5.7 ) Actual result: -------------- Array ( [0] => 0.3 [1] => 0.4 ) PHP Warning: range(): step exceeds the specified range Array ( [0] => 5.5 [1] => 5.6 [2] => 5.7 ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50679&edit=1
