⬅️ 二进制左移(逻辑左移 <<)Shift Binary Left
把二进制数向左移动若干位(<<):右边补 0,每左移 1 位数值乘以 2。可以让结果变长(保留所有位),也可以保持原来的位数或固定位宽(8 / 16 / 32 位),此时从左边移出的位会被丢弃,并提示丢掉了哪些位、是否溢出。可同时处理多个数并显示十进制结果,适合学习位运算、乘以 2 的幂和汇编练习,数据在本地处理。Shift binary numbers left (<<): zeros come in on the right and each position doubles the value. Let the result grow so no bits are lost, or keep the original length or a fixed width (8, 16 or 32 bits), in which case the bits pushed out on the left are dropped and the tool tells you which were lost and whether it overflowed. Process many values at once and show decimal results. Handy for learning bit operations, multiplying by powers of two and assembly exercises. Processed locally.
使用说明与常见问题How-to & FAQ
「二进制左移(逻辑左移 <<)」是什么?What is the Shift Binary Left tool?
把二进制数向左移动若干位(<<):右边补 0,每左移 1 位数值乘以 2。可以让结果变长(保留所有位),也可以保持原来的位数或固定位宽(8 / 16 / 32 位),此时从左边移出的位会被丢弃,并提示丢掉了哪些位、是否溢出。可同时处理多个数并显示十进制结果,适合学习位运算、乘以 2 的幂和汇编练习,数据在本地处理。Shift binary numbers left (<<): zeros come in on the right and each position doubles the value. Let the result grow so no bits are lost, or keep the original length or a fixed width (8, 16 or 32 bits), in which case the bits pushed out on the left are dropped and the tool tells you which were lost and whether it overflowed. Process many values at once and show decimal results. Handy for learning bit operations, multiplying by powers of two and assembly exercises. Processed locally.
如何使用「二进制左移(逻辑左移 <<)」?How do I use the Shift Binary Left tool?
在「二进制左移(逻辑左移 <<)」中,把内容粘贴或输入到上方输入框,按需设置「移动位数」、「结果位数」、「固定位宽(可选)」,结果会实时显示在下方,点击「复制结果」即可复制。例如输入「1011」,得到「10110」。In the Shift Binary Left: Paste or type into the input box, adjust "Positions", "Result length", "Fixed width (optional)"; the result appears below instantly — click "Copy result" to copy it. Example: "1011" → "10110".
怎样输入多个值?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).
左移 1 位为什么等于乘以 2?Why does shifting left by 1 double the value?
二进制每一位的权重是右边一位的 2 倍,整体左移 1 位后,每个 1 都移到权重翻倍的位置,右边补 0,所以数值 × 2;左移 n 位就是 × 2ⁿ。例如 1011(11)左移 2 位是 101100(44)。如果保持固定位数,左边移出的 1 会丢失,这就是溢出,结果不再等于 × 2ⁿ。Each binary place is worth twice the place to its right. Shifting everything left by 1 moves every 1 to a place worth double and adds a 0 on the right, so the value doubles; shifting by n multiplies by 2ⁿ. For example 1011 (11) shifted left by 2 is 101100 (44). With a fixed length, any 1 pushed off the left is lost — that is overflow, and the result is no longer × 2ⁿ.
“结果变长”和“保持原位数”怎么选?Should the result grow or keep its length?
做数学运算(乘以 2 的幂)时选“结果变长”,不会丢失任何位;模拟 CPU 寄存器或 C 语言里固定宽度整数的 << 时,选“保持原位数”或填写固定位宽(8 / 16 / 32),超出部分会被丢弃,工具会提示有没有 1 被移出。Choose Let it grow for maths (multiplying by powers of two) — no bit is lost. To mimic a CPU register or a fixed-width integer << in C, choose Keep the length or set a fixed width (8, 16 or 32); bits beyond it are dropped and the tool tells you whether any 1s were pushed out.
输入和输出是什么样的?What does the input and output look like?
例如在「二进制左移(逻辑左移 <<)」中输入 1011,输出为:10110(⏎ 表示换行)。For example, the Shift Binary Left turns the input 1011 into: 10110 (⏎ marks a line break).
有哪些选项可以调整?What options can I adjust?
「二进制左移(逻辑左移 <<)」的设置:「移动位数」默认 1;「结果位数」可选 结果变长(不丢位)/ Let it grow (no bits lost)、保持原位数(丢弃移出的位)/ Keep the length (drop bits)(默认 结果变长(不丢位)/ Let it grow (no bits lost));「固定位宽(可选)」可留空;可勾选:「同时显示十进制」、「加 0b 前缀」、「每 4 位加空格」。改动任一选项后结果会按新设置重新生成。Settings in the Shift Binary Left — "Positions" default 1; "Result length": 结果变长(不丢位)/ Let it grow (no bits lost), 保持原位数(丢弃移出的位)/ Keep the length (drop bits) (default 结果变长(不丢位)/ Let it grow (no bits lost)); "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 Left runs entirely in local JavaScript, so it is safe for data containing keys or internal endpoints.
「二进制左移(逻辑左移 <<)」免费吗?需要注册吗?Is the Shift Binary Left free? Do I need an account?
「二进制左移(逻辑左移 <<)」完全免费,无需注册或安装,打开网页即可使用,手机和电脑都能用;输入的内容只在你的浏览器本地处理。The Shift Binary Left is completely free with no sign-up or install and works on phones and desktops; what you enter is processed only in your browser.