smitthhyy Posted September 12, 2009 Share Posted September 12, 2009 This has got me stumped. Hoping someone has a clue on how to get around it: $a = 77; $b = 78; $c = 23; if ( ( (($a - $b) >> 4) || (($b - $a) >> 4) ) && ($c != 1) ) Statemenet evaluates TRUE if ( ( ((77 - 78) >> 4) || ((78 - 77) >> 4) ) && (23 != 1) ) if ( ( (-1 >> 4) || (1 >> 4) ) && (23 != 1) ) if ( ( (TRUE) || (FALSE ) ) && (TRUE) ) When I went to school, -1 was smaller than +4. Using PHP5 Thanks. Link to comment https://forums.phpfreaks.com/topic/173996-solved-negative-numbers-evaluate-as-greater-than-positive-numbers/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 12, 2009 Share Posted September 12, 2009 Two >> is not a comparison operator, it is a bit shift operator. Link to comment https://forums.phpfreaks.com/topic/173996-solved-negative-numbers-evaluate-as-greater-than-positive-numbers/#findComment-917197 Share on other sites More sharing options...
smitthhyy Posted September 12, 2009 Author Share Posted September 12, 2009 Doh! Solved Statemenet evaluates FALSE if ( ( ((77 - 78) > 4) || ((78 - 77) > 4) ) && (23 != 1) ) if ( ( (-1 > 4) || (1 > 4) ) && (23 != 1) ) if ( ( (FALSE) || (FALSE ) ) && (TRUE) ) Link to comment https://forums.phpfreaks.com/topic/173996-solved-negative-numbers-evaluate-as-greater-than-positive-numbers/#findComment-917199 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.