We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fbd314e commit 580ed60Copy full SHA for 580ed60
1 file changed
doc/BitSet.md
@@ -6,6 +6,31 @@
6
x is odd
7
}
8
```
9
- - 测试nth bit是否设置:`x & (1 << n)`
10
- - 设置nth bit:`x | (1 << n)`
11
- -
+ - Test if the n-th bit is set
+ ```
+ if (x & (1 << n)) {
12
+ n-th bit is set
13
+ } else {
14
+ n-th bit is not set
15
+ }
16
17
+ - Set the n-th bit
18
19
+ y = x | (1 << n)
20
21
+ - Unset the n-th bit
22
23
+ y = x & ~(1 << n)
24
25
+ - Toggle the n-th bit
26
27
+ y = x ^ (1 << n)
28
29
+ - Turn off the rightmost 1-bit
30
31
+ y = x & (x - 1)
32
33
+ - Isolate the rightmost 1-bit
34
35
+ y = x & (-x)
36
0 commit comments