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

边栏推荐
- 第5讲 使用pytorch实现线性回归
- BFC(Block Formatting Context)
- 学习总结day5
- Do you use tomatoes to supervise your peers?Add my study room, come on together
- 位运算符与逻辑运算符的区别
- CAP+BASE
- day12函数进阶作业
- Convert the paper official seal in the form of a photo into an electronic official seal (no need to download ps)
- 1.3 mysql批量插入数据
- 学习总结week2_4
猜你喜欢
随机推荐
CAP+BASE
【NFT网站】教你制作开发NFT预售网站官网Mint作品
2022杭电多校第一场01
Returned object not currently part of this pool
npm搭建本地服务器,直接运行build后的目录
Algorithms - ones and zeros (Kotlin)
Lecture 2 Linear Model Linear Model
DOM及其应用
有用番茄来监督自己的同道中人吗?加一下我的自习室,一起加油
day7-列表作业(1)
Map、WeakMap
Detailed Explanation of Redis Sentinel Mode Configuration File
redis persistence
【记一下1】2022年6月29日 哥和弟 双重痛苦
RDD和DataFrame和Dataset
el-table鼠标移入表格改变显示背景色
数据库实验五 备份与恢复
server disk array
转正菜鸟前进中的经验(废话)之谈 持续更新中... ...
Error creating bean with name 'configDataContextRefresher' defined in class path resource









