当前位置:网站首页>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.
边栏推荐
- ES6 生成器
- 学习总结week2_4
- Geek卸载工具
- Flink HA安装配置实战
- [Study Notes Dish Dog Learning C] Classic Written Exam Questions of Dynamic Memory Management
- 第四讲 back propagation 反向传播
- The mall background management system based on Web design and implementation
- "PHP8 Beginner's Guide" A brief introduction to PHP
- js实现数组去重
- el-table,el-table-column,selection,获取多选选中的数据
猜你喜欢
解决端口占用问题
【练一下1】糖尿病遗传风险检测挑战赛 【讯飞开放平台】
[Go through 7] Notes from the first section of the fully connected neural network video
OFDM 十六讲 5 -Discrete Convolution, ISI and ICI on DMT/OFDM Systems
el-table,el-table-column,selection,获取多选选中的数据
server disk array
Flink 状态与容错 ( state 和 Fault Tolerance)
Database experiment five backup and recovery
OFDM Lecture 16 5 -Discrete Convolution, ISI and ICI on DMT/OFDM Systems
【过一下6】机器视觉视频 【过一下2被挤掉了】
随机推荐
RDD和DataFrame和Dataset
【过一下3】卷积&图像噪音&边缘&纹理
el-table,el-table-column,selection,获取多选选中的数据
[Remember 1] June 29, 2022 Brother and brother double pain
【MySQL】数据库多表链接的查询方式
周末作业-循环练习题(2)
学习总结week3_2函数进阶
[WeChat applet] WXML template syntax - conditional rendering
What are the characteristics of the interface of the physical layer?What does each contain?
拿出接口数组对象中的所有name值,取出同一个值
The role of the range function
OFDM Lecture 16 5 -Discrete Convolution, ISI and ICI on DMT/OFDM Systems
coppercam primer [6]
npm搭建本地服务器,直接运行build后的目录
数据库 单表查询
【过一下10】sklearn使用记录
[Go through 7] Notes from the first section of the fully connected neural network video
Multi-threaded query results, add List collection
【Transfer】What is etcd
js实现数组去重