当前位置:网站首页>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.

边栏推荐
猜你喜欢

Database experiment five backup and recovery

el-pagination左右箭头替换成文字上一页和下一页

【过一下4】09-10_经典网络解析

Lecture 2 Linear Model Linear Model
![coppercam入门手册[6]](/img/d3/a7d44aa19acfb18c5a8cacdc8176e9.png)
coppercam入门手册[6]
![[Let's pass 14] A day in the study room](/img/fc/ff4161db8ed13a0c8ef75b066b8eab.png)
[Let's pass 14] A day in the study room

pycharm中调用Matlab配置:No module named ‘matlab.engine‘; ‘matlab‘ is not a package

DOM及其应用
![LeetCode: 1403. Minimum subsequence in non-increasing order [greedy]](/img/99/41629dcd84e95eb3672d0555d6ef2c.png)
LeetCode: 1403. Minimum subsequence in non-increasing order [greedy]

【过一下7】全连接神经网络视频第一节的笔记
随机推荐
CAP+BASE
学习总结week2_5
JSX基础
02.01-----The role of parameter reference "&"
shell函数
多线程查询结果,添加List集合
What are the characteristics of the interface of the physical layer?What does each contain?
学习总结week3_3迭代器_模块
es6迭代协议
Flink HA安装配置实战
vscode要安装的插件
Lecture 3 Gradient Tutorial Gradient Descent and Stochastic Gradient Descent
Transformation 和 Action 常用算子
OFDM 十六讲 5 -Discrete Convolution, ISI and ICI on DMT/OFDM Systems
2022 The 4th C.Easy Counting Problem (EGF+NTT)
RDD和DataFrame和Dataset
转正菜鸟前进中的经验(废话)之谈 持续更新中... ...
【MySQL】数据库多表链接的查询方式
【过一下14】自习室的一天
day7-列表作业(1)