X Tutup
Skip to content

Commit b3e8102

Browse files
author
liwentian
committed
fd
1 parent 580ed60 commit b3e8102

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

doc/BitSet.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,23 @@
2626
```
2727
y = x ^ (1 << n)
2828
```
29-
- Turn off the rightmost 1-bit
29+
- Turn off the rightmost 1-bit,将最右边的1清零
3030
```
3131
y = x & (x - 1)
3232
```
33-
- Isolate the rightmost 1-bit
33+
- Isolate the rightmost 1-bit,留下最右边的1,其余位都置为0
3434
```
3535
y = x & (-x)
36+
```
37+
- Right propagate the rightmost 1-bit,将最右边的1的右边全部置为1
38+
```
39+
y = x | (x - 1)
40+
```
41+
- Isolate the rightmost 0-bit,将最右边的0置为1,其余位都置为0
42+
```
43+
y = ~x & (x + 1)
44+
```
45+
- Turn on the rightmost 0-bit,将最右边的0置为1
46+
```
47+
y = x | (x + 1)
3648
```

0 commit comments

Comments
 (0)
X Tutup