C Programming - Bitwise Operators - Discussion

Discussion Forum : Bitwise Operators - Yes / No Questions (Q.No. 4)
Bitwise | can be used to multiply a number by powers of 2.
Answer: Option
No answer description is available. Let's discuss.
4 comments Page 1 of 1.

Ionut said:   8 years ago
<< (LEFT SHIFT n positions) multiplies by 2^n.

>> (RIGHT SHIFT n positions) divides by 2^n.

Abhayraj SN said:   8 years ago
<< (LEFT SHIFT) multiplies by 2.
>> (RIGHT SHIFT) divides by 2.

Correct me if it's wrong!

Ranjit said:   1 decade ago
Multiplying by a power of 2 is the same as shifting to the left. If you shift it left by 3 places you multiply it by 2^3=8. Similarly shifting to the right is division by powers of 2.

Raushan said:   1 decade ago
For power operation, multiplication is done repeatedly the same number of time as is the number. Direct bitwise operation for power is not available.

Post your comments here:

Your comments will be displayed after verification.