Monday, January 26, 2009

Bit Operators in C Program

C has several operators for logical bit-operations. For example,
x = x & 0177;
forms the bit-wise AND of x and 0177, effectively retaining only the last seven bits of x. Other operators are
| inclusive OR
^ (circumflex) exclusive OR
~ (tilde) 1's complement
! logical NOT
<< left shift (as in x<<2)
>> right shift (arithmetic on PDP-11; logical on H6070, IBM360)

No comments:

Post a Comment