If you have any query feel free to chat us!
Happy Coding! Happy Learning!
In C, there are also three bitwise shift operators that can be used to shift the bits of a number left or right:
Example: 5 1
Malformed citation << 2; // results in 20 (5 * 2^2) 2. Right Shift (>>): The right shift operator shifts the bits of the first operand to the right by the number of positions specified by the second operand. This has the effect of dividing the first operand by 2 raised to the power of the second operand. Example: 20 >>
Example: ~5; // results in -6
It is important to note that bitwise shift operators can be used with both integers and characters in C. It is also important to note that the shift operation can lead to undefined behavior if the shift amount is greater or equal than the size of the type of the left-hand side expression.
Comments: 0