84669 人學習
152542 人學習
20005 人學習
5487 人學習
7821 人學習
359900 人學習
3350 人學習
180660 人學習
48569 人學習
18603 人學習
40936 人學習
1549 人學習
1183 人學習
32909 人學習
stl源码剖析的第61页有上面的位运算,不过我不了解,求证明。
闭关修行中......
7 = 00000111b& is bitwise ANDso the x&7 has the only 3 low bits of x.
~7 = 11111000b
so the x&~7 will set x's 3 low bits to 0, and it is the multiple of 8.
(x+n-1)&(n-1),把x增大稍大於x的n的倍數,前提是n必須為2^mbecause only 2^m-1 has the type : high bits must be 1, low bits must be 0 , not intersected.
(x+n-1)&(n-1)
2^m-1
subnet mask 子網路遮罩
7 = 00000111b
& is bitwise AND
so the x&7 has the only 3 low bits of x.
~7 = 11111000b
so the x&~7 will set x's 3 low bits to 0, and it is the multiple of 8.
(x+n-1)&(n-1)
,把x增大稍大於x的n的倍數,前提是n必須為2^mbecause only
2^m-1
has the type : high bits must be 1, low bits must be 0 , not intersected.subnet mask 子網路遮罩