当前位置:网站首页>Bitwise logical operator
Bitwise logical operator
2022-07-06 08:34:00 【There is no place to find a bug after treading on iron shoes. I】
One 、 According to the not :~
In the computer , Data is stored in binary , Even with the original code 、 Inverse code 、 Complement code . Binary numbers are stored in memory in the form of complements .
According to the not Is to take each digit of the complement inversely , namely 0 change 1,1 change 0;
#include <stdio.h>
int main()
{
char a = 5;
printf("%d", ~a);
return 0;
}
The result is -6;
Positive integer :5
The original code of a positive number 、 Inverse code 、 The complement is the same :00000101
According to the not :11111010 // At this time, the reverse result is the original code , It also needs to be converted into a complement
Inverse code :10000101
Complement code :10000110
result :-6
Negtive integer :-5
Original code :10000101
Inverse code :11111010
Complement code :11111011
According to the not :00000100 // At this time, the reverse result is the original code , Because the original code is positive , The former is the same as the latter
result :4
The bitwise negation of a positive number equals itself +1 The negative number of
The bitwise negation of a negative number equals itself +1 Positive number of
0 Reverse by bit to -1
Two 、 Bitwise AND :&
[ The rules ]
0&0=0
0&1=0
1&0=0
1&1=1
#include <stdio.h>
int main()
{
char a = 5,b=9;
char c = a&b;
printf("%d", c);
return 0;
}
The result is 1
5 Complement :00000101
9 Complement :00001001
Bitwise and post results :00000001 // At this time, the result is the original code , Because the original code is positive , The former is the same as the latter
result :1
3、 ... and 、 Press bit or :|
[ The rules ]
0|0=0
0|1=1
1|0=1
1|1=1
#include <stdio.h>
int main()
{
char a = 5,b=9;
char c = a|b;
printf("%d", c);
return 0;
}
The result is 13
5 Complement :00000101
9 Complement :00001001
Bitwise or post result :00001101 // At this time, the result is the original code , Because the original code is positive , The former is the same as the latter
result :13
Four 、 Bitwise XOR :^
[ The rules ]
0^0=0
0^1=1
1^0=1
1^1=0
#include <stdio.h>
int main()
{
char a = 5,b=9;
char c = a^b;
printf("%d", c);
return 0;
}
The result is 12
5 Complement :00000101
9 Complement :00001001
Bitwise and or post result :00001100 // At this time, the result is the original code , Because the original code is positive , The former is the same as the latter
result :12
边栏推荐
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- China dihydrolaurenol market forecast and investment strategy report (2022 Edition)
- How to conduct interface test? What are the precautions? Nanny level interpretation
- Leetcode question brushing (5.31) string
- VMware virtualization cluster
- Zhong Xuegao, who cannot be melted, cannot escape the life cycle of online celebrity products
- C語言雙指針——經典題型
- synchronized 解决共享带来的问题
- 2022 Inner Mongolia latest construction tower crane (construction special operation) simulation examination question bank and answers
- sublime text的编写程序时的Tab和空格缩进问题
猜你喜欢
[cloud native topic -45]:kubesphere cloud Governance - Introduction and overall architecture of enterprise container platform based on kubernetes
[MySQL] database stored procedure and storage function clearance tutorial (full version)
leetcode刷题 (5.28) 哈希表
Visual implementation and inspection of visdom
Use Alibaba icon in uniapp
2. File operation - write
Indentation of tabs and spaces when writing programs for sublime text
sublime text的编写程序时的Tab和空格缩进问题
JVM 快速入门
2022.02.13 - 238. Maximum number of "balloons"
随机推荐
egg. JS getting started navigation: installation, use and learning
[cloud native] teach you how to build ferry open source work order system
Research Report on Market Research and investment strategy of microcrystalline graphite materials in China (2022 Edition)
[2022 Guangdong saim] Lagrange interpolation (multivariate function extreme value divide and conquer NTT)
Leetcode question brushing (5.28) hash table
角色动画(Character Animation)的现状与趋势
被破解毁掉的国产游戏之光
[brush questions] top101 must be brushed in the interview of niuke.com
2022 Inner Mongolia latest water conservancy and hydropower construction safety officer simulation examination questions and answers
String to leading 0
Research and investment forecast report of citronellol industry in China (2022 Edition)
延迟初始化和密封类
2022.02.13 - NC002. sort
Deep learning: derivation of shallow neural networks and deep neural networks
pcd转ply后在meshlab无法打开,提示 Error details: Unespected eof
LDAP应用篇(4)Jenkins接入
Colorlog结合logging打印有颜色的日志
查看局域网中电脑设备
The mysqlbinlog command uses
软件卸载时遇到trying to use is on a network resource that is unavailable