当前位置:网站首页>Shift Operators
Shift Operators
2022-07-06 08:34:00 【There is no place to find a bug after treading on iron shoes. I】
One 、 Move left :<<
Move the complement of a number to the left , use 0 fill
#include <stdio.h>
int main()
{
char a = 65;
char c = a<<1;
printf("%d", c);
return 0;
}
The result is :-126
Positive numbers :65
The positive number is the same as the inverse complement :01000001
Result after left shift :10000010 // This is the original code after moving , Need to be converted to complement
Inverse code :11111101
Complement code :11111110
result :-126
negative :-65
Original code :11000001
Inverse code :10111110
Complement code :10111111
Move to the left :01111110 // The original code is a positive number , The former is the same as the latter
result :126
Two 、 Move right :>>
Move the complement of the number to the right , For unsigned numbers , use 0 fill , For signed numbers , Fill with sign bits .
#include <stdio.h>
int main()
{
char a = -7;
char c = a>>2;
printf("%d", c);
return 0;
}
The result is -2
negative :-7
Original code :10000111
Inverse code :11111000
Complement code :11111001
The result after moving right :11111110 // This is the original code after moving , Need to be converted to complement
Inverse code :10000001
Complement code :10000010
result :-2
Positive numbers :7
The positive number is the same as the inverse complement :00000111
The result after moving right :00000001 // This is the original code after moving , It's a positive number , The former is the same as the latter
result :1
边栏推荐
- 【MySQL】鎖
- JS native implementation shuttle box
- logback1.3. X configuration details and Practice
- On the day of resignation, jd.com deleted the database and ran away, and the programmer was sentenced
- 目标检测——Pytorch 利用mobilenet系列(v1,v2,v3)搭建yolov4目标检测平台
- 2022.02.13 - NC004. Print number of loops
- Precise query of tree tree
- C語言雙指針——經典題型
- 如何进行接口测试测?有哪些注意事项?保姆级解读
- Summary of phased use of sonic one-stop open source distributed cluster cloud real machine test platform
猜你喜欢
visdom可视化实现与检查介绍
【MySQL】锁
egg. JS project deployment online server
Indentation of tabs and spaces when writing programs for sublime text
CISP-PTE实操练习讲解
Mobile phones and computers on the same LAN access each other, IIS settings
Visual implementation and inspection of visdom
2022 Inner Mongolia latest water conservancy and hydropower construction safety officer simulation examination questions and answers
Cisp-pte practice explanation
堆排序详解
随机推荐
[cloud native topic -45]:kubesphere cloud Governance - Introduction and overall architecture of enterprise container platform based on kubernetes
2. File operation - write
Screenshot in win10 system, win+prtsc save location
leetcode刷题 (5.29) 哈希表
2022.02.13 - NC002. sort
JVM performance tuning and practical basic theory - Part 1
pytorch训练好的模型在加载和保存过程中的问题
Cisp-pte practice explanation
leetcode刷题 (5.28) 哈希表
Pointer advanced --- pointer array, array pointer
Trying to use is on a network resource that is unavailable
2022.02.13 - NC004. Print number of loops
堆排序详解
Research and investment forecast report of citronellol industry in China (2022 Edition)
On the inverse order problem of 01 knapsack problem in one-dimensional state
torch建立的网络模型使用torchviz显示
How to conduct interface test? What are the precautions? Nanny level interpretation
IoT -- 解读物联网四层架构
C language custom type: struct
synchronized 解决共享带来的问题