# Right shift (>>)

## 在此页

right shift operator ( ``` >> ``` ) shifts the first operand the specified number of bits to the right. Excess bits shifted off to the right are discarded. Copies of the leftmost bit are shifted in from the left. Since the new leftmost bit has the same value as the previous leftmost bit, the sign bit (the leftmost bit) does not change. Hence the name "sign-propagating".

## 句法

````a >> b`
```

## 描述

This operator shifts the first operand the specified number of bits to the right. Excess bits shifted off to the right are discarded. Copies of the leftmost bit are shifted in from the left. Since the new leftmost bit has the same value as the previous leftmost bit, the sign bit (the leftmost bit) does not change. Hence the name "sign-propagating".

```.    9 (base 10): 00000000000000000000000000001001 (base 2)
--------------------------------
9 >> 2 (base 10): 00000000000000000000000000000010 (base 2) = 2 (base 10)
```

Likewise, ``` -9 >> 2 ``` yields ``` -3 ``` , because the sign is preserved:

```.    -9 (base 10): 11111111111111111111111111110111 (base 2)
--------------------------------
-9 >> 2 (base 10): 11111111111111111111111111111101 (base 2) = -3 (base 10)
```

## 范例

### Using right shift

``` 9 >> 2; //  2
-9 >> 2; // -3
```

## 浏览器兼容性

 Desktop Mobile Server Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100

## 另请参阅

1. JavaScript
2. 教程：
3. 完整初学者
4. JavaScript 指南
5. 中间体
6. 高级
7. 参考：
8. 内置对象
9. 表达式 & 运算符
10. 语句 & 声明
11. 函数
12. 错误
13. 杂项