C Tutorial Bitwise operators
Introduction to C language
Integer types
Char constants
Int constants
Type combination and promotion
Int overflow
Floating point types
Comments
Variables
Assignment operator
Truncation
Int vs float arithmatic
Mathematical operators
Unary Increment Operators
Pre and Post Variations
C Programming Cleverness and Ego Issues
Relational Operators
Logical Operators
Bitwise Operators
Other Assignment Operators

 

 
 
 
 

 

HOME
 

C includes operators to manipulate memory at the bit level. This is useful for writing low-

level hardware or operating system code where the ordinary abstractions of numbers,

characters, pointers, etc... are insufficient -- an increasingly rare need. Bit manipulation

code tends to be less "portable". Code is "portable" if with no programmer intervention it

compiles and runs correctly on different types of computers. The bitwise operations are

typically used with unsigned types. In particular, the shift operations are guaranteed to

shift 0 bits into the newly vacated positions when used on unsigned values.

 

~      Bitwise Negation (unary) flip 0 to 1 and 1 to 0 throughout

 

&      Bitwise And

 

|      Bitwise Or

 

^      Bitwise Exclusive Or

 

>>     Right Shift by right hand side (RHS) (divide by power of 2)

 

<<     Left Shift by RHS (multiply by power of 2)

 

Do not confuse the Bitwise operators with the logical operators. The bitwise connectives are one character wide (&, |) while the boolean connectives are two characters wide (&&,

||). The bitwise operators have higher precedence than the boolean operators. The

compiler will never help you out with a type error if you use & when you meant &&. As

far as the type checker is concerned, they are identical-- they both take and produce

integers since there is no distinct boolean type.

Want more information and Video ???