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 22:05
Modified:
  08/28/06 22:28

Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#123237 - difference
Responding to: ???'s previous message
hi,

let say once again: && (logical AND) and & (bitwise AND) have total different means! This is in basical C-kernel manual.

simple example:
(1000b && 1) !=0 results in not zero value (read TRUE as long as you not redefine basic TRUE value which is defined as any not FALSE (zero by definition)) because BOTH values are not zero;
while
(1000b & 1) results in ZERO.

so in
if ((tmp && 0x01) !=0) /* test LSB */

when tmp is 11xxx for shift iterrations < 5
is always true:

shift = 1:
(11xx && 1) != 0 <- TRUE
shift = 2:
(11x && 1) != 0 <- TRUE
shift = 3:
(11 && 1) != 0 <- TRUE
shift = 4:
(1 && 1) != 0 <- TRUE

So you do send always 1 as output value on serial stream.

BTW: for big iterrations the result may be different depends on the typedef int size und compiler, be careful due sign bit!

Please read C manual careful and you catch difference between logical and bitwise operands!

Regards,
Oleg

[sorry for multiple edition due third hour of night]

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