➡️ 二进制右移(逻辑右移 >>> / 算术右移 >>)Shift Binary Right
把二进制数向右移动若干位:逻辑右移(>>>)在左边补 0,算术右移(>>)在左边补符号位(最高位),适合有符号补码数。默认保持原来的位数,也可以去掉移出的位让结果变短;会提示从右边移出了哪些 1(被舍去的余数)。每右移 1 位相当于除以 2 向下取整,可同时处理多个数并显示十进制结果,数据在本地处理。Shift binary numbers right. A logical shift (>>>) brings in zeros on the left; an arithmetic shift (>>) copies the sign bit (the top bit), which suits signed two's-complement numbers. The length is kept by default, or the shifted-out bits can simply be removed so the result gets shorter, and the tool tells you which 1s fell off the right (the discarded remainder). Each position divides by 2 rounding down. Process many values at once and show decimal results. Processed locally.
使用说明与常见问题How-to & FAQ
「二进制右移(逻辑右移 >>> / 算术右移 >>)」是什么?What is the Shift Binary Right tool?
把二进制数向右移动若干位:逻辑右移(>>>)在左边补 0,算术右移(>>)在左边补符号位(最高位),适合有符号补码数。默认保持原来的位数,也可以去掉移出的位让结果变短;会提示从右边移出了哪些 1(被舍去的余数)。每右移 1 位相当于除以 2 向下取整,可同时处理多个数并显示十进制结果,数据在本地处理。Shift binary numbers right. A logical shift (>>>) brings in zeros on the left; an arithmetic shift (>>) copies the sign bit (the top bit), which suits signed two's-complement numbers. The length is kept by default, or the shifted-out bits can simply be removed so the result gets shorter, and the tool tells you which 1s fell off the right (the discarded remainder). Each position divides by 2 rounding down. Process many values at once and show decimal results. Processed locally.
如何使用「二进制右移(逻辑右移 >>> / 算术右移 >>)」?How do I use the Shift Binary Right tool?
在「二进制右移(逻辑右移 >>> / 算术右移 >>)」中,把内容粘贴或输入到上方输入框,按需设置「移动位数」、「类型」、「结果位数」、「固定位宽(可选)」,结果会实时显示在下方,点击「复制结果」即可复制。例如输入「1011」,得到「0101」。In the Shift Binary Right: Paste or type into the input box, adjust "Positions", "Type", "Result length", "Fixed width (optional)"; the result appears below instantly — click "Copy result" to copy it. Example: "1011" → "0101".
怎样输入多个值?How do I enter several values?
每行一个,或用空格、逗号、分号分隔;每个值单独处理,原来的换行和分隔符保持不变。可以带 0b 前缀(结果也会保留),数中间的下划线会被忽略(如 1010_1100)。Put one value per line or separate them with spaces, commas or semicolons; each value is handled on its own and the original lines and separators are kept. A 0b prefix is fine (and kept in the result), and underscores inside a value are ignored (1010_1100).
逻辑右移和算术右移有什么区别?What is the difference between logical and arithmetic shifts?
逻辑右移把数当作无符号数,左边一律补 0;算术右移把最高位当作符号位,左边补和最高位一样的值,这样负数(补码最高位是 1)右移后仍是负数,结果等于除以 2ⁿ 向下取整。例如 4 位补码 1011(−5)算术右移 1 位得到 1101(−3)。JavaScript 和 Java 里 >>> 是逻辑右移,>> 是算术右移。A logical shift treats the value as unsigned and always fills the left with 0. An arithmetic shift treats the top bit as the sign and fills with copies of it, so a negative two's-complement number stays negative and the result is the value divided by 2ⁿ, rounded down. For example the 4-bit 1011 (−5) shifted right arithmetically by 1 is 1101 (−3). In JavaScript and Java, >>> is the logical shift and >> the arithmetic one.
移出的位去哪了?Where do the shifted-out bits go?
从右边移出的位会被丢弃,相当于除法的余数被舍去,工具会提示有没有 1 被移出。选择“去掉移出的位”时结果会变短(不在左边补位),适合直接得到 ⌊x ÷ 2ⁿ⌋ 的二进制;默认保持原位数,和寄存器的行为一致。Bits that fall off the right are thrown away, like discarding the remainder of a division, and the tool tells you whether any 1s were lost. Drop the shifted-out bits makes the result shorter (nothing is added on the left), which gives ⌊x ÷ 2ⁿ⌋ directly; by default the length is kept, as a register would.
输入和输出是什么样的?What does the input and output look like?
例如在「二进制右移(逻辑右移 >>> / 算术右移 >>)」中输入 1011,输出为:0101(⏎ 表示换行)。For example, the Shift Binary Right turns the input 1011 into: 0101 (⏎ marks a line break).
有哪些选项可以调整?What options can I adjust?
「二进制右移(逻辑右移 >>> / 算术右移 >>)」的设置:「移动位数」默认 1;「类型」可选 逻辑右移(左边补 0)/ Logical (fill with 0)、算术右移(补符号位)/ Arithmetic (copy the sign bit)(默认 逻辑右移(左边补 0)/ Logical (fill with 0));「结果位数」可选 保持原位数、去掉移出的位(变短)/ Drop the shifted-out bits(默认 保持原位数);「固定位宽(可选)」可留空;可勾选:「同时显示十进制」、「加 0b 前缀」、「每 4 位加空格」。改动任一选项后结果会按新设置重新生成。Settings in the Shift Binary Right — "Positions" default 1; "Type": 逻辑右移(左边补 0)/ Logical (fill with 0), 算术右移(补符号位)/ Arithmetic (copy the sign bit) (default 逻辑右移(左边补 0)/ Logical (fill with 0)); "Result length": Keep the length, 去掉移出的位(变短)/ Drop the shifted-out bits (default Keep the length); "Fixed width (optional)" optional; tick boxes: "Also show decimal", "Add 0b prefix", "Space every 4 bits". Changing any option regenerates the result with the new setting.
代码或数据会被上传吗?Is my code or data uploaded?
不会。「二进制右移(逻辑右移 >>> / 算术右移 >>)」完全用 JavaScript 在本地运行,适合处理含有密钥、内部接口等敏感内容的数据。No. The Shift Binary Right runs entirely in local JavaScript, so it is safe for data containing keys or internal endpoints.
「二进制右移(逻辑右移 >>> / 算术右移 >>)」免费吗?需要注册吗?Is the Shift Binary Right free? Do I need an account?
「二进制右移(逻辑右移 >>> / 算术右移 >>)」完全免费,无需注册或安装,打开网页即可使用,手机和电脑都能用;输入的内容只在你的浏览器本地处理。The Shift Binary Right is completely free with no sign-up or install and works on phones and desktops; what you enter is processed only in your browser.