🔍

首页Home › 开发工具Developer Tools

🔄 二进制循环移位(位旋转 ROL / ROR)Rotate Binary Bits

把二进制数的位循环移动:向左旋转(ROL)时,左边移出的位从右边补回来;向右旋转(ROR)时,右边移出的位回到左边,1 的个数不变。可以设置旋转位数和位宽(默认按每个数自己的位数,也可以固定为 8、16、32 位并在左边补 0),可同时处理多个数,并显示十进制结果。适合学习位运算、哈希和加密算法(如 SHA、循环移位寄存器)以及汇编练习,数据在本地处理。Rotate the bits of binary numbers. Rotating left (ROL) moves the bits that fall off the left back in on the right; rotating right (ROR) moves the bits from the right back to the left, so the number of 1s never changes. Set how many positions to rotate and the bit width (each value's own length by default, or a fixed 8, 16 or 32 bits with leading zeros), process many values at once and show decimal results. Handy for learning bit operations, hash and cipher algorithms (SHA, rotating shift registers) and assembly exercises. Processed locally.

使用说明与常见问题How-to & FAQ

「二进制循环移位(位旋转 ROL / ROR)」是什么?What is the Rotate Binary Bits tool?

把二进制数的位循环移动:向左旋转(ROL)时,左边移出的位从右边补回来;向右旋转(ROR)时,右边移出的位回到左边,1 的个数不变。可以设置旋转位数和位宽(默认按每个数自己的位数,也可以固定为 8、16、32 位并在左边补 0),可同时处理多个数,并显示十进制结果。适合学习位运算、哈希和加密算法(如 SHA、循环移位寄存器)以及汇编练习,数据在本地处理。Rotate the bits of binary numbers. Rotating left (ROL) moves the bits that fall off the left back in on the right; rotating right (ROR) moves the bits from the right back to the left, so the number of 1s never changes. Set how many positions to rotate and the bit width (each value's own length by default, or a fixed 8, 16 or 32 bits with leading zeros), process many values at once and show decimal results. Handy for learning bit operations, hash and cipher algorithms (SHA, rotating shift registers) and assembly exercises. Processed locally.

如何使用「二进制循环移位(位旋转 ROL / ROR)」?How do I use the Rotate Binary Bits tool?

在「二进制循环移位(位旋转 ROL / ROR)」中,把内容粘贴或输入到上方输入框,按需设置「方向」、「旋转位数」、「位宽(留空 = 各自位数)」,结果会实时显示在下方,点击「复制结果」即可复制。例如输入「10110001」,得到「01100011」。In the Rotate Binary Bits: Paste or type into the input box, adjust "Direction", "Positions", "Bit width (blank = own length)"; the result appears below instantly — click "Copy result" to copy it. Example: "10110001" → "01100011".

怎样输入多个值?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).

旋转和移位有什么区别?How is rotating different from shifting?

移位(Shift)会把移出去的位丢掉,空出来的位置补 0(或补符号位);旋转(Rotate)会把移出去的位从另一端补回来,所以不会丢失任何位,1 的个数也不变。例如 8 位的 10110001 左移 1 位是 01100010,循环左移 1 位是 01100011。A shift throws away the bits that fall off and fills the gap with 0 (or the sign bit). A rotation brings those bits back in at the other end, so nothing is lost and the number of 1s stays the same. For example the 8-bit 10110001 shifted left by 1 is 01100010, rotated left by 1 it is 01100011.

位宽有什么影响?What does the bit width change?

旋转是在固定位数里进行的:留空时按每个数自己的位数(包括前导 0)旋转;填写 8、16、32 等位宽时,先在左边补 0 到这个位数再旋转,这和 CPU 的 ROL/ROR 指令一致。例如 101 按 8 位循环左移 1 位得到 00001010。如果数的有效位超过位宽会提示错误。Rotation happens within a fixed number of bits. Left blank, each value rotates within its own length (leading zeros included). With a width such as 8, 16 or 32 the value is first padded with leading zeros to that width, matching the CPU ROL/ROR instructions — 101 rotated left by 1 in 8 bits is 00001010. A value with more significant bits than the width gives an error.

旋转位数大于位宽会怎样?What if I rotate by more than the width?

旋转一整圈(位数等于位宽)会回到原样,所以实际旋转的位数是“旋转位数 ÷ 位宽”的余数,例如 4 位的数旋转 5 位等于旋转 1 位。Rotating by the full width brings the value back to where it started, so the effective rotation is the remainder of positions ÷ width — rotating a 4-bit value by 5 is the same as rotating it by 1.

输入和输出是什么样的?What does the input and output look like?

例如在「二进制循环移位(位旋转 ROL / ROR)」中输入 10110001,输出为:01100011(⏎ 表示换行)。For example, the Rotate Binary Bits turns the input 10110001 into: 01100011 (⏎ marks a line break).

有哪些选项可以调整?What options can I adjust?

「二进制循环移位(位旋转 ROL / ROR)」的设置:「方向」可选 向左(ROL)/ Left (ROL)、向右(ROR)/ Right (ROR)(默认 向左(ROL)/ Left (ROL));「旋转位数」默认 1;「位宽(留空 = 各自位数)」可留空;可勾选:「同时显示十进制」、「加 0b 前缀」、「每 4 位加空格」。改动任一选项后结果会按新设置重新生成。Settings in the Rotate Binary Bits — "Direction": 向左(ROL)/ Left (ROL), 向右(ROR)/ Right (ROR) (default 向左(ROL)/ Left (ROL)); "Positions" default 1; "Bit width (blank = own length)" 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?

不会。「二进制循环移位(位旋转 ROL / ROR)」完全用 JavaScript 在本地运行,适合处理含有密钥、内部接口等敏感内容的数据。No. The Rotate Binary Bits runs entirely in local JavaScript, so it is safe for data containing keys or internal endpoints.

「二进制循环移位(位旋转 ROL / ROR)」免费吗?需要注册吗?Is the Rotate Binary Bits free? Do I need an account?

「二进制循环移位(位旋转 ROL / ROR)」完全免费,无需注册或安装,打开网页即可使用,手机和电脑都能用;输入的内容只在你的浏览器本地处理。The Rotate Binary Bits is completely free with no sign-up or install and works on phones and desktops; what you enter is processed only in your browser.

相关工具Related tools

⬅️ 二进制左移(逻辑左移 <<)Shift Binary Left➡️ 二进制右移(逻辑右移 >>> / 算术右移 >>)Shift Binary Right⚙️ 位运算计算器Bitwise Calculator🔀 二进制位随机打乱(洗牌,保持 1 的个数)Shuffle Binary Bits⊕ 二进制 XOR 运算(按位异或)XOR Binary Values⊙ 二进制 XNOR 运算(同或)XNOR Binary Values❝ CSV 加引号(按需或强制)Add CSV Quotes❞ CSV 去引号(去掉不必要的字段引号)Remove CSV Quotes↔️ CSV 更换分隔符(逗号 / 分号 / 制表符)Change CSV Delimiter“ CSV 更换引号样式(双引号 / 单引号)Change CSV Quote Style📊 CSV 分析(行列统计 / 列类型预览)Analyze CSV📄 CSV 转文本(按分隔符拆成纯文本)Convert CSV to Text

← 全部工具All tools