当前位置:网站首页>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 mysqlbinlog command uses
- C language double pointer -- classic question type
- [secretly kill little partner pytorch20 days -day01- example of structured data modeling process]
- Image, CV2 read the conversion and size resize change of numpy array of pictures
- Analysis of the source code of cocos2d-x for mobile game security (mobile game reverse and protection)
- 电脑F1-F12用途
- IoT -- 解读物联网四层架构
- [cloud native] teach you how to build ferry open source work order system
- Deep analysis of C language pointer
- Deep learning: derivation of shallow neural networks and deep neural networks
猜你喜欢

PLT in Matplotlib tight_ layout()

深度剖析C语言数据在内存中的存储

Restful API design specification

On the day of resignation, jd.com deleted the database and ran away, and the programmer was sentenced

egg. JS project deployment online server

深度剖析C语言指针

Double pointeur en langage C - - modèle classique

synchronized 解决共享带来的问题

Bottom up - physical layer

优秀的软件测试人员,都具备这些能力
随机推荐
C語言雙指針——經典題型
Synchronized solves problems caused by sharing
根据csv文件某一列字符串中某个数字排序
IoT -- 解读物联网四层架构
Mobile phones and computers on the same LAN access each other, IIS settings
MySQL learning record 11jdbcstatement object, SQL injection problem and Preparedstatement object
LDAP Application Section (4) Jenkins Access
C语言深度解剖——C语言关键字
visdom可视化实现与检查介绍
Double pointeur en langage C - - modèle classique
JVM 快速入门
CISP-PTE实操练习讲解
@JsonBackReference和@JsonManagedReference(解决对象中存在双向引用导致的无限递归)
Wincc7.5 download and installation tutorial (win10 system)
Restful API design specification
View computer devices in LAN
Research Report on Market Research and investment strategy of microcrystalline graphite materials in China (2022 Edition)
Golang force buckle leetcode 1020 Number of enclaves
个人电脑好用必备软件(使用过)
Sublime text in CONDA environment plt Show cannot pop up the problem of displaying pictures