Bitwise Operators in C - C Reference

C examples for Reference:Language Reference

Introduction

Operator Name Description
~ Bitwise unary NOTIt inverts the value of bit
& Bitwise AND Result is 1 if both bits are 1, otherwise result is 0.
| Bitwise OR Result is 0 if both bits are 0, otherwise result is 1.
^ Bitwise XOR Result is 1 if one bit is 1 and other bit is 0, otherwise result is 0
<<Left shift Shift the bits to left and fill the vacated bits with 0.
>>Right shift Shift the bits to right and : (a) in case of unsigned quantity fills the vacated bits with 0, and (b) in case of signed quantity fills the vacated bits with 0 (logical shift) on some machines and with sign bits (arithmetic shift) on other machines.

Related Tutorials