Unsigned Right Shift
The unsigned right shift operator is >>>. It shifts all bits in a number to the right. For positive numbers, the effect is the same as a signed right shift.
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script type="text/javascript">
var oldValue = 64; //equal to binary 1000000
var newValue = oldValue >>> 5; //equal to binary 10 which is decimal 2
document.writeln(newValue);//2
</script>
</head>
<body>
</body>
</html>
For negative numbers unsigned-right-shift operator considers the binary representation of the negative number to be representative of a positive number.
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script type="text/javascript">
var oldValue = -64; //
var newValue = oldValue >>> 5; //
document.writeln(newValue);//134217726
</script>
</head>
<body>
</body>
</html>
Home
JavaScript Book
Language Basics
JavaScript Book
Language Basics
Operators:
- JavaScript Operators
- Increment/Decrement Operators
- Increment/Decrement Operators for String, Boolean, Floating-point and Object
- Unary Plus and Minus
- Bitwise Not operator
- Bitwise AND
- Bitwise OR
- Bitwise XOR
- Left Shift
- Signed Right Shift
- Unsigned Right Shift
- Logical NOT
- Logical AND
- Logical OR
- Multiply
- Divide
- Modulus
- Add
- Subtract
- Relational Operators
- Equal and Not Equal
- Identically Equal and Not Identically Equal
- Conditional Operator
- Assignment Operators
- Comma Operator