位运算¶
约 93 个字
概览¶
| 符号 | 描述 | 运算规则 |
|---|---|---|
| & | 与 | 当两位都为 1 时,结果才为 1 |
| | | 或 | 当两位都为 0 时,结果才为 0 |
| ^ | 异或 | 两位相同时为 0,相异时为 1 |
| ~ | 取反 | 0 变为 1,1 变为 0 |
| << | 左移 | 各二进位全部左移若干位,高位丢弃,低位补 0 |
| >> | 右移 | 各二进位全部右移若干位,高位补 0 或符号位补齐 |
流程图¶
- 与 (&)
graph LR;
input1[INPUT1] --> and{AND &}
input2[INPUT2] --> and
and -->|If INPUT1 = INPUT2 = 1| output1(1)
and -->|Else| output2(0) - 或 (|)
graph LR;
input1[INPUT1] --> and{"OR |"}
input2[INPUT2] --> and
and -->|If INPUT1 = INPUT2 = 0| output1(0)
and -->|Else| output2(1) - 异或 (^)