按位取反
This commit is contained in:
parent
ce8fa14892
commit
428eaec33c
|
@ -0,0 +1,13 @@
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int n = 10;
|
||||||
|
cout << "~10 = " << ~n << endl; // -11 : ~ 位非运算符: 二进制取反: 0000 1010 => 1111 0101 => -11
|
||||||
|
n = -9;
|
||||||
|
cout << "~(-9) = " << ~n << endl; // 8 : ~ 位非运算符: 二进制取反: 1000 1001 => 0111 0110 => 8
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue