We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0110609 commit 2a0a69bCopy full SHA for 2a0a69b
UpdateHistory.md
@@ -118,3 +118,17 @@ https://github.com/jackzhenguo/LeetCodeManager
118
return dist;
119
}
120
```C#
121
+ ## Bit Mainpulation
122
+ * [CSDN:#476 Number Complement](http://blog.csdn.net/daigualu/article/details/72843822)
123
+ > get bits for a number</br>
124
+ ```C#
125
+ public int FindComplement(int num)
126
+ {
127
+ int bits = 1; //num including bits
128
+ while (Math.Pow(2, bits) <= num)
129
+ bits++;
130
+ int sum = (int) Math.Pow(2, bits) - 1;//sum =Pow(2,n)-1: sum of n bits 1
131
+ return sum - num; //sum - num is the complement
132
+
133
+ }
134
+ ```
0 commit comments