🔀 二进制 OR 运算(按位或)OR Binary Values
把两个或多个二进制数按位做 OR(或)运算:任何一个数在该位是 1,结果就是 1。可以每行一组分别计算,也可以把所有数一起计算;位数不同时右端对齐左边补 0,可显示竖式、十进制和十六进制结果。适合学习位运算、设置权限位和标志位、数字电路练习,数据在本地处理。Apply bitwise OR to two or more binary values: a result bit is 1 if any value has a 1 there. Work each line separately or combine all values; different lengths are right-aligned with leading zeros. Show the working and the result in decimal and hex too. Handy for learning bitwise logic, setting permission or flag bits and digital-logic exercises. Processed locally.
使用说明与常见问题How-to & FAQ
「二进制 OR 运算(按位或)」是什么?What is the OR Binary Values tool?
把两个或多个二进制数按位做 OR(或)运算:任何一个数在该位是 1,结果就是 1。可以每行一组分别计算,也可以把所有数一起计算;位数不同时右端对齐左边补 0,可显示竖式、十进制和十六进制结果。适合学习位运算、设置权限位和标志位、数字电路练习,数据在本地处理。Apply bitwise OR to two or more binary values: a result bit is 1 if any value has a 1 there. Work each line separately or combine all values; different lengths are right-aligned with leading zeros. Show the working and the result in decimal and hex too. Handy for learning bitwise logic, setting permission or flag bits and digital-logic exercises. Processed locally.
如何使用「二进制 OR 运算(按位或)」?How do I use the OR Binary Values tool?
在「二进制 OR 运算(按位或)」中,把内容粘贴或输入到上方输入框,按需设置「计算方式」、「位数不同时」、「最少位数(可选)」,结果会实时显示在下方,点击「复制结果」即可复制。In the OR Binary Values: Paste or type into the input box, adjust "Combine", "Different lengths", "Minimum width (optional)"; the result appears below instantly — click "Copy result" to copy it.
怎样输入多个数?How do I enter several values?
每行一个数,或在同一行里用空格、逗号、分号或加号(+)分隔;可以带 0b 前缀,数中间的下划线会被忽略(如 1010_1100)。“自动”方式下:如果有一行包含两个以上的数,就每行单独计算;否则所有数一起计算。Put one value per line, or separate them with spaces, commas, semicolons or plus signs (+) on a line. A 0b prefix is fine and underscores inside a value are ignored (1010_1100). In Auto mode, if any line holds two or more values each line is worked out on its own; otherwise all values are combined.
位数不同的数怎么对齐?How are values of different lengths lined up?
按右端(最低位)对齐,短的数在左边补 0,例如 101 和 11 按 101 和 011 计算,结果的位数等于最长的数(或你设置的“最少位数”)。如果希望位数不同时报错,把“位数不同时”改为“报错”。They are right-aligned on the lowest bit and shorter values get leading zeros, so 101 and 11 are treated as 101 and 011; the result is as long as the longest value (or the Minimum width you set). Choose "Show an error" under Different lengths if mismatched lengths should be rejected.
OR 的真值表是什么?What is the OR truth table?
0 OR 0 = 0,0 OR 1 = 1,1 OR 0 = 1,1 OR 1 = 1。多个数做 OR 时,只要有一个数在该位是 1,结果就是 1。常用来把某些标志位设为 1,例如 权限 OR 0100 打开某个权限位。0 OR 0 = 0, 0 OR 1 = 1, 1 OR 0 = 1, 1 OR 1 = 1. With several values a bit is 1 if any of them has a 1 there. It's the usual way to switch flag bits on, e.g. permissions OR 0100 turns one permission bit on.
结果的位数是多少?How many bits does the result have?
结果保留和最长的输入(或“最少位数”)一样多的位,包括前导 0,例如 1100 NAND 1010 = 0111,而不是 111;这样每一位都能和输入对应上。The result keeps as many bits as the longest input (or the Minimum width), leading zeros included, so every bit lines up with the inputs.
代码或数据会被上传吗?Is my code or data uploaded?
不会。「二进制 OR 运算(按位或)」完全用 JavaScript 在本地运行,适合处理含有密钥、内部接口等敏感内容的数据。No. The OR Binary Values runs entirely in local JavaScript, so it is safe for data containing keys or internal endpoints.
「二进制 OR 运算(按位或)」免费吗?需要注册吗?Is the OR Binary Values free? Do I need an account?
「二进制 OR 运算(按位或)」完全免费,无需注册或安装,打开网页即可使用,手机和电脑都能用;输入的内容只在你的浏览器本地处理。The OR Binary Values is completely free with no sign-up or install and works on phones and desktops; what you enter is processed only in your browser.