当前位置:网站首页>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
边栏推荐
- 被破解毁掉的国产游戏之光
- pytorch训练好的模型在加载和保存过程中的问题
- 深度剖析C语言指针
- 【刷题】牛客网面试必刷TOP101
- Visual implementation and inspection of visdom
- logback1.3. X configuration details and Practice
- swagger设置字段required必填
- Wincc7.5 download and installation tutorial (win10 system)
- MySQL learning record 07 index (simple understanding)
- 2022.02.13 - NC004. Print number of loops
猜你喜欢

Zhong Xuegao, who cannot be melted, cannot escape the life cycle of online celebrity products

【MySQL】鎖

Visual implementation and inspection of visdom

生成器参数传入参数

Summary of phased use of sonic one-stop open source distributed cluster cloud real machine test platform

JVM performance tuning and practical basic theory - Part 1

vulnhub hackme: 1

marathon-envs项目环境配置(强化学习模仿参考动作)

优秀的软件测试人员,都具备这些能力

Sublime text using ctrl+b to run another program without closing other runs
随机推荐
China polyether amine Market Forecast and investment strategy report (2022 Edition)
JVM performance tuning and practical basic theory - Part 1
C语言深度解剖——C语言关键字
Leetcode skimming (5.29) hash table
poi追加写EXCEL文件
2022.02.13 - NC002. sort
Image, CV2 read the conversion and size resize change of numpy array of pictures
Configuring OSPF load sharing for Huawei devices
ROS编译 调用第三方动态库(xxx.so)
String to leading 0
游戏解包的危害及资源加密的重要性
Permutation and combination function
Summary of phased use of sonic one-stop open source distributed cluster cloud real machine test platform
JS native implementation shuttle box
VMware virtualization cluster
Generator parameters incoming parameters
gcc动态库fPIC和fpic编译选项差异介绍
JVM performance tuning and practical basic theory - Part 1
[secretly kill little partner pytorch20 days -day01- example of structured data modeling process]
Research and investment forecast report of citronellol industry in China (2022 Edition)