Arithmetic and logical binary operators in c programming language
The C Programming Language 2nd ed. Wikipedia articles needing style editing from March All articles needing style editing. The number following the operator decides the number of places the bits are shifted i.
Views Read Edit View history. The number following the operator decides the number of places the bits are shifted i. To be used as a logical operator!
This page was last edited on 22 Februaryat March Learn how and when to remove this template message. It shifts each bit in its left-hand operand to the left by the number of positions indicated by the right-hand operand.
Its result is a 1 if one of the either bits is 1 and zero only when both bits are 0. The reason for this is that a byte is normally the smallest unit of addressable memory i. The result is zero only when we have two zeroes or two ones. C provides a compound assignment operator for each binary arithmetic and bitwise operation i. When performed on an unsigned type, the operation performed is a logical shiftcausing the blanks to be filled by 0 s zeros.
This article is written like a manual or guidebook. Another difference is that logical operators perform short-circuit evaluation. When performed on a signed type, the result is technically undefined and compiler dependant,  however most compilers will perform an arithmetic shiftcausing the blank to be filled with the sign bit of the left operand.