JavaScript/右位移:修订间差异
来自康健生活
创建页面,内容为“== 引言 == == 右位移 ==” |
|||
| 第1行: | 第1行: | ||
== 引言 == | == 引言 == | ||
== 右位移 == | == 右位移 == | ||
假定值为 125。 | |||
{{leftrightflex|<syntaxhighlight lang="javascript"> | |||
const foo = 125; | |||
console.log(foo.toString(2));</syntaxhighlight>|{{consoleout|<pre> | |||
1111101 | |||
</pre>}}}} | |||
补全之后的内容为。 | |||
<pre> | |||
0000 0000 0000 0000 0000 0000 0111 1101</pre> | |||
右移三个单位。 | |||
{{leftrightflex|<syntaxhighlight lang="javascript"> | |||
console.log(125 >> 3);</syntaxhighlight>|{{consoleout|<pre> | |||
15 | |||
</pre>}}}} | |||
补全之后的内容为。 | |||
<pre> | |||
0000 0000 0000 0000 0000 0000 0000 1111 | |||
</pre> | |||
其中 <code>0111 1101</code> 中的末尾的 <code>101</code> 将被丢弃。 | |||