当前位置:网站首页>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
边栏推荐
- Use Alibaba icon in uniapp
- C language - bit segment
- VMware 虚拟化集群
- Zhong Xuegao, who cannot be melted, cannot escape the life cycle of online celebrity products
- 从表中名称映射关系修改视频名称
- Leetcode question brushing (5.31) string
- Hungry for 4 years + Ali for 2 years: some conclusions and Thoughts on the road of research and development
- 企微服务商平台收费接口对接教程
- China vanadium battery Market Research and future prospects report (2022 Edition)
- [secretly kill little partner pytorch20 days -day01- example of structured data modeling process]
猜你喜欢
Fibonacci sequence
MySQL learning record 11jdbcstatement object, SQL injection problem and Preparedstatement object
指针进阶---指针数组,数组指针
leetcode刷题 (5.28) 哈希表
Ruffian Heng embedded bimonthly, issue 49
JVM performance tuning and practical basic theory - Part 1
Sublime text using ctrl+b to run another program without closing other runs
Restful API design specification
JS inheritance method
2022.02.13 - 238. Maximum number of "balloons"
随机推荐
Chrome浏览器的crash问题
如何进行接口测试测?有哪些注意事项?保姆级解读
Sublime text in CONDA environment plt Show cannot pop up the problem of displaying pictures
目标检测——Pytorch 利用mobilenet系列(v1,v2,v3)搭建yolov4目标检测平台
3. File operation 3-with
Pointer advanced --- pointer array, array pointer
pcd转ply后在meshlab无法打开,提示 Error details: Unespected eof
What is CSRF (Cross Site Request Forgery)?
2022.02.13 - NC003. Design LRU cache structure
[2022 广东省赛M] 拉格朗日插值 (多元函数极值 分治NTT)
tree树的精准查询
PLT in Matplotlib tight_ layout()
Configuring OSPF load sharing for Huawei devices
Screenshot in win10 system, win+prtsc save location
按位逻辑运算符
Purpose of computer F1-F12
[secretly kill little partner pytorch20 days -day01- example of structured data modeling process]
2022 Inner Mongolia latest construction tower crane (construction special operation) simulation examination question bank and answers
Leetcode skimming (5.29) hash table
【ROS】usb_cam相机标定