Running the following JavaScript code shows 63 in both cases:
alert( 0xff >> 2 );
alert( 0xff >>> 2 );
What is the differences between >> and >>>? Their results seem to be equal.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
>>is a bitwise operator, which shift the bits to the right. Any bits at the right are lost.>>>does the similar thing as>>, but it’s unsigned, which means that it ranges from 0 to 232-1 instead of +/- 231-1.To see the result of my first statement in action, let’s use the bitwise operator to floor a number:
So, when the upper boundary of a range is exceeded, the calculation will continue at its lower range, and vice versa (eg
<<). The following illustrates shows what happens when you usen = (n + 1) >> 0, and>>> 0, fornstarting at the lowest boundary.