当前位置:网站首页>The difference between the operators and logical operators
The difference between the operators and logical operators
2022-08-05 05:25:00 【Xmn_】
Bitwise operators include four kinds of '&' , ' ~' , '| ', '^'.
Bit operation is to first convert the data to two's complement form, and then gradually calculate bit by bit.Where
"~" is the "bitwise NOT" operator, the rule: 1 is 0, 0 is 1.
"&" is the "bitwise AND" operator, the rule: all 1s are 1, otherwise it is 0.
"^" is the "bitwise XOR" operator, the rule: the same is 0, the difference is 1.
"|" is the "bitwise OR" operator, the rule: all 0 are 0, otherwise it is 1.Such as:
Calculate 3|6=x
3 0011
6 | 0110
x 0111=7
So 3|6=7.
Note:
The bitwise XOR operation is reversible, that is, if the same XOR operation is performed on a certain data a twice, the result will be restored to a, such as the value 3 and 5 are performed twiceXOR:
3 ^ 5 = 6;
6 ^ 5 = 3;
Logical operatorThere are three kinds of
'&&' , and logical AND
'||' , logical OR
'!', logical NOT
The operation rules are as follows:
Summary the difference between the two
1) Logical operators can only perform calculations on Boolean types, but bit operations can perform logical operations on numerical values.
2) There is a short circuit phenomenon in logical operators, that is, when the previous expression is judged to be successful, the latter expression will not be executed.
边栏推荐
猜你喜欢
jvm three heap and stack
[Student Graduation Project] Design and Implementation of the Website Based on the Web Student Information Management System (13 pages)
NodeJs接收上传文件并自定义保存路径
[Go through 8] Fully Connected Neural Network Video Notes
CAP+BASE
将照片形式的纸质公章转化为电子公章(不需要下载ps)
Using pip to install third-party libraries in Pycharm fails to install: "Non-zero exit code (2)" solution
pycharm中调用Matlab配置:No module named ‘matlab.engine‘; ‘matlab‘ is not a package
【NFT开发】设计师无技术基础保姆级开发NFT教程在Opensea上全套开发一个NFT项目+构建Web3网站
拿出接口数组对象中的所有name值,取出同一个值
随机推荐
2022杭电多校第一场01
学习总结week3_1函数
coppercam primer [6]
【Reading】Long-term update
【NFT网站】教你制作开发NFT预售网站官网Mint作品
LeetCode: 1403. Minimum subsequence in non-increasing order [greedy]
Opencv中,imag=cv2.cvtColor(imag,cv2.COLOR_BGR2GRAY) 报错:error:!_src.empty() in function ‘cv::cvtColor‘
Transformation 和 Action 常用算子
Pandas(五)—— 分类数据、读取数据库
[Redis] Resid的删除策略
【过一下8】全连接神经网络 视频 笔记
OFDM Lecture 16 5 -Discrete Convolution, ISI and ICI on DMT/OFDM Systems
多线程查询结果,添加List集合
有用番茄来监督自己的同道中人吗?加一下我的自习室,一起加油
Matplotlib(三)—— 实践
小白一枚各位大牛轻虐虐
【Untitled】
es6迭代协议
2022 The 4th C.Easy Counting Problem (EGF+NTT)
HQL语句执行过程