Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能的重复: 按位运算和使用
x 是输入。需要输入 0、1、x 或 x̅ :
x & 0 = 0 x & 1 = x x | 0 = x x | 1 = 0 x ^ 0 = 1 x ^ 1 =
如果x是布尔值,那么!x是 x 的布尔否定。那是你的“翻转”。
x
!x
要打开和关闭,只需执行x = 1和x = 0
x = 1
x = 0
x & 0 = 0 x & 1 = x x | 0 = x x | 1 = 1 x ^ 0 = x x ^ 1 = 0 if x is 1, 1 if x is 0