Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/28/06 19:37
Modified:
  08/28/06 19:39

Read: times


 
#123229 - \'&\' in an if statement
Responding to: ???'s previous message
'&' in an if statement is for the test only, the value is not affected

tmp = x
tmp = (val >> n) & 0x01; /* isolate the bit */
tmp STILL =x

However, for let's say n = 2, after the first line : 

tmp = 0000 0110 & 0x01 ; -> 0000 0000 
hence, the next line again check, 
if((0000 0110 && 0000 0001) != 0)
So for this case, the result is NOT '0'

if the above was not the case, you could not do this:
if (ralph & 0x01)
{
...
)
else if (ralph & 0x02)
{
...
)


erik

List of 6 messages in thread
TopicAuthorDate
ADC0838 does not output correctly            01/01/70 00:00      
   here?            01/01/70 00:00      
      Hmm..i dont understand why            01/01/70 00:00      
         \'&\' in an if statement            01/01/70 00:00      
            The line is not inside an \\\'if\\\' statement            01/01/70 00:00      
         difference            01/01/70 00:00      

Back to Subject List