当前位置:网站首页>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
边栏推荐
- On the day of resignation, jd.com deleted the database and ran away, and the programmer was sentenced
- Image, CV2 read the conversion and size resize change of numpy array of pictures
- 同一局域网的手机和电脑相互访问,IIS设置
- Research Report on Market Research and investment strategy of microcrystalline graphite materials in China (2022 Edition)
- synchronized 解决共享带来的问题
- 按位逻辑运算符
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- [cloud native topic -45]:kubesphere cloud Governance - Introduction and overall architecture of enterprise container platform based on kubernetes
- View computer devices in LAN
- ROS编译 调用第三方动态库(xxx.so)
猜你喜欢
3. File operation 3-with
2022.02.13 - 238. Maximum number of "balloons"
visdom可视化实现与检查介绍
Sublime text in CONDA environment plt Show cannot pop up the problem of displaying pictures
MySQL learning record 11jdbcstatement object, SQL injection problem and Preparedstatement object
同一局域网的手机和电脑相互访问,IIS设置
2022 Inner Mongolia latest construction tower crane (construction special operation) simulation examination question bank and answers
Indentation of tabs and spaces when writing programs for sublime text
软件卸载时遇到trying to use is on a network resource that is unavailable
Online yaml to CSV tool
随机推荐
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
C language - bit segment
Use Alibaba icon in uniapp
Process of obtaining the electronic version of academic qualifications of xuexin.com
查看局域网中电脑设备
Analysis of the source code of cocos2d-x for mobile game security (mobile game reverse and protection)
@JsonBackReference和@JsonManagedReference(解决对象中存在双向引用导致的无限递归)
hutool优雅解析URL链接并获取参数
Generator parameters incoming parameters
C language custom type: struct
logback1.3. X configuration details and Practice
MySQL learning record 11jdbcstatement object, SQL injection problem and Preparedstatement object
egg. JS getting started navigation: installation, use and learning
2022 Inner Mongolia latest water conservancy and hydropower construction safety officer simulation examination questions and answers
电脑清理,删除的系统文件
pcd转ply后在meshlab无法打开,提示 Error details: Unespected eof
MySQL learning record 07 index (simple understanding)
Sublime text in CONDA environment plt Show cannot pop up the problem of displaying pictures
C语言深度解剖——C语言关键字
Deep analysis of C language data storage in memory