vmars316 Posted April 23, 2013 Share Posted April 23, 2013 lieCheck = 0; if (lieCheck |= 1) { } if (lieCheck == 1) { } Both of these get executed .What am I doing wrong ?Thanks..vm Link to comment Share on other sites More sharing options...
Ingolme Posted April 23, 2013 Share Posted April 23, 2013 The |= operator assigns the logical OR operation between the left and right operands to the left variable. if lieCheck is 0 then 0 | 1 is 1 which is equivalent to a boolean True. Anything operated with 1 will return a truth value because the 1 will always ensure that the last bit is set to 1. Maybe you wanted to use the & operator instead. 1 Link to comment Share on other sites More sharing options...
vmars316 Posted April 24, 2013 Author Share Posted April 24, 2013 The |= operator assigns the logical OR operation between the left and right operands to the left variable. if lieCheck is 0 then 0 | 1 is 1 which is equivalent to a boolean True. Anything operated with 1 will return a truth value because the 1 will always ensure that the last bit is set to 1. Maybe you wanted to use the & operator instead. Thanks..vm Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now