How can we calculate the shift distance in shift operators?

The shift distance is calculated by AND-ing the value of the right-hand operand with a mask value of 0x1f (31) if the left-hand has the promoted type int, or using a mask value of 0x3f (63) if the left-hand has the promoted type long. This effectively means masking the five lower bits of the right-hand operand in the case of an int left-hand operand, and masking the six lower bits of the right-hand operand in the case of a long left-hand operand. Thus, the shift distance is always in the range 0 to 31 when the promoted type of left-hand operand is int, and in the range 0 to 63 when the promoted type of left-hand operand is long.

Questions by sujatham   answers by sujatham

 

This Question is not yet answered!

 
 

Related Answered Questions

 

Related Open Questions