However, do note that a shift operand value which is either a negative number or is greater than or equal to the total number of bits in this value results in undefined behavior.
Example: Here blank spaces are generated simultaneously on the left when the bits are shifted to the right.
When performed on an unsigned type or a non-negative value in a signed type, the operation performed is a logical shift, causing the blanks to be filled by 0s (zeros).
When performed on a negative value in a signed type, the result is technically implementation-defined (compiler dependent),[5] however most compilers will perform an arithmetic shift, causing the blank to be filled with the set sign bit of the left operand.
Example: The output of the above program will be The symbol of left shift operator is <<.
However, do note that a shift operand value which is either a negative number or is greater than or equal to the total number of bits in this value results in undefined behavior.
This is defined in the standard at ISO 9899:2011 6.5.7 Bit-wise shift operators.
However, logical operators treat each operand as having only one value, either true or false, rather than treating each bit of an operand as an independent value.
Logical operators consider zero false and any nonzero value true.
Another difference is that logical operators perform short-circuit evaluation.
A logical not applied to both operands will not change the truth table that results but will ensure all nonzero values are converted to the same value before comparison.