Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2a0a69b

Browse files
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

Lines changed: 14 additions & 0 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /