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? 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); 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 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 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) Link to comment https://forums.phpfreaks.com/topic/193343-php-inequalities-problem/#findComment-1018043 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.