|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-07-03 11:46 UTC] tony2001@php.net
[2007-07-03 13:52 UTC] c00lways at gmail dot com
[2007-07-03 14:06 UTC] tony2001@php.net
[2007-07-03 14:07 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 10:00:01 2025 UTC |
Description: ------------ int added by float ended as not equal to float equavalent value Reproduce code: --------------- //this output <empty>, not 1 echo isValidRange( 5.23, 1, 10, 0.01 ); //this output 1 //echo 5.23 == (1+4.23); function isValidRange( $p_value, $p_start, $p_end, $p_step=1 ) { //reverse step if( $p_end < $p_start ) { $p_step = -($p_step); } if( $p_step == 0.000000 ) { raiseError(1, "Invalid step: " . $p_step); } for( $c = $p_start; $c <= $p_end; $c+=$p_step ) { //this part caused the problem if( $p_value == $c ) { return true; } //if change it to //if( $p_value."" == $c."" ) // then it works! return true } return false; } Expected result: ---------------- 1 Actual result: -------------- <empty>