Renlok Posted February 25, 2010 Share Posted February 25, 2010 i have an if statement if ($bid < $next_bid) and it $bid & $next_bid hold the same values. php seems to think the statement is true. is this a bug in php or something? Quote Link to comment https://forums.phpfreaks.com/topic/193343-php-inequalities-problem/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 25, 2010 Share Posted February 25, 2010 What does the following show (i.e. you are asking someone to attempt to tell you why a comparison is not working without any information about the actual values being compared) - var_dump($bid); echo '<br />'; var_dump($next_bid); Quote Link to comment https://forums.phpfreaks.com/topic/193343-php-inequalities-problem/#findComment-1018014 Share on other sites More sharing options...
Renlok Posted February 25, 2010 Author Share Posted February 25, 2010 It shows string(4) "0.29" float(0.29) EDIT: but even if i change it to var_dump(floatval($bid)); echo '<br />'; var_dump($next_bid); if (floatval($bid) < $next_bid) it shows float(0.29) float(0.29) but the if statement still returns as true Quote Link to comment https://forums.phpfreaks.com/topic/193343-php-inequalities-problem/#findComment-1018017 Share on other sites More sharing options...
PFMaBiSmAd Posted February 25, 2010 Share Posted February 25, 2010 Read the Warning at this link - http://us.php.net/float Quote Link to comment https://forums.phpfreaks.com/topic/193343-php-inequalities-problem/#findComment-1018021 Share on other sites More sharing options...
Renlok Posted February 25, 2010 Author Share Posted February 25, 2010 OK thanks i finally go it to work with the bccomp() function now i have if (bccomp($bid, $next_bid, 2) == -1) Quote Link to comment https://forums.phpfreaks.com/topic/193343-php-inequalities-problem/#findComment-1018043 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.