Skip to content

Commit 2a0a69b

Browse files
committed
update history
1 parent 0110609 commit 2a0a69b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

UpdateHistory.md

+14
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,17 @@ https://github.com/jackzhenguo/LeetCodeManager
118118
return dist;
119119
}
120120
```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

Comments
 (0)