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:28
Modified:
  08/28/06 19:35

Read: times


 
#123228 - Hmm..i dont understand why
Responding to: ???'s previous message
tmp = (val >> n) & 0x01; /* isolate the bit */
if ((tmp && 0x01) !=0) /* test LSB */


lets say the val is in 11001

after the first line, for n = 4,
tmp = 0000 0001 & 0x01; -> 0000 0001

the next line check
if((0000 0001 && 0000 0001) != 0)

Of course in this case, the condition is if statement is fulfilled since the result is '1'.


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 0000 && 0000 0001) != 0)
So for this case, the result is '0'

I dont understand why you said that the line always yield 1 as result. Please let me know.


P/S - Is it the fact i have used && instead of &? Since & is a bitwise operator.



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