Thread: One line power
View Single Post
  #7   Spotlight this post!  
Unread 04-03-2002, 23:22
Mike Soukup's Avatar
Mike Soukup Mike Soukup is offline
Software guy
FRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1996
Location: Schaumburg, IL
Posts: 797
Mike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond repute
Bitwise operator

In C the common ones are bitwise OR | bitwise AND & and (please correct me if I'm wrong, my C book is at work) bitwise XOR ^

What the operators do is take the number in binary and perform the operation (or, and, xor) on the corresponding bits.

OR evaluates to 1 if either input is 1, 0 otherwise
AND evaluates to 1 if both inputs are 1, 0 otherwise
XOR evaluates to 1 if only 1 (not both) inputs are 1, 0 otherwise

Example:
148 | 51 -> 10010100 | 00110011 = 10110111 -> 183
148 & 51 -> 10010100 | 00110011 = 00010000 -> 16
148 ^ 51 -> 10010100 | 00110011 = 10100111 -> 167

If you take an intro to computer engineering class in college, you'll learn this within the first couple of weeks. If you have more questions ask away, we're here to help.

Mike