当前位置:网站首页>Some operations of bit operation
Some operations of bit operation
2022-07-28 15:32:00 【Flying_】
Bitwise AND & The operation is usually used to clear some bits of a number or reserve some bits
for example : hold a The height of 8 A reset
a & 0000000011111111
Also is to a & 255 After the operation , Will realize the number a The height of 8 Bit is cleared
Exclusive or ^ Purpose of operation :
Flip certain bits
For example, logarithm 0x10100001 Of the 2 And the 3 Bit flip operation , that
Sure 0x10100001 ^ 0x00000110
Through bitwise XOR operation, the exchange of two numbers can be realized
For example, exchange A and B
A=0x10100001 B=0x00000110
A=A^B A=10100111
B=A^B B=10100001
A=A^B A=00000110
Some operations of bit operation :
1、 Multiplication and division 2
Numbers A Move left n Who said A*2^n
Numbers A Move right n Who said A/2^n
2、 Judge parity
Because if a digit is odd , Then the last one must be 1, All and 1 Carry out the positioning & operation , Must be 1, It can be judged to be an odd number , If the result is 0 Then it's even
0x00010000
&
0x00000001
Int a = 16;
Int b= 25;
If(a & 1)
Odd number
Else
even numbers
边栏推荐
- 19、通道分配任务定义
- .net core 3.1版本配置跨域问题
- 4、主程序和累积中断处理例程实现代码
- ERROR:bokeh.core.validation. check:E-1001 (BAD_COLUMN_NAME)
- Collation of MySQL error prone knowledge points (to be updated)
- Svg verification code recognition experience
- R introduction example details
- crmeb知识付费手动安装教程
- Solve the problem of pycharm using PowerShell
- Shellcode writing learning environment
猜你喜欢
随机推荐
9、相关数据累积任务定义
Tencent interview -- please design a thread pool to implement sequential execution
Pytorch - autograd automatic differentiation
Problems encountered by pyppeter
Daily question (retrospective)
R introduction example details
[leetcode] 35. Search the insertion position
Chrome plug-in debugging
Grpc frequently asked questions
HJS-DE1/2时间继电器
Svg verification code recognition experience
Crmeb Standard Edition window+phpstudy8 installation tutorial (III)
Leetcode - random set, longest multiclass subsequence
How to write a JMeter script common to the test team
crmeb标准版附带的客服系统
MIT指出公开预训练模型不能乱用
Srtt-110vdc-4h-c time relay
Qt信号与槽的五种连接方式
PMP [agile textbook + full truth simulation question]. After the exam on June 25, agile has become the top priority
游戏测试的概念是什么?测试方法和流程有哪些?








