当前位置:网站首页>Shift right of negative numbers
Shift right of negative numbers
2022-07-27 04:39:00 【Third brother】
Only right shift is discussed here , Shift left positive and negative numbers are the same , The lowest point is made up of 0.
In the computer , Numerical values are operated in binary form , also The operation object of bit operator is complement .
Positive numbers : Original code = Inverse code = Complement code
negative : Original code ----> Inverse code ( Take the opposite ) ----> Complement code (+1)
demonstration :
Put a positive integer 10 Move two places to the right
Original code :0000 0000 0000 0000 0000 0000 0000 1010Because it's a positive number , Therefore, the displacement can be directly operated .
The calculation result is 0000 0000 0000 0000 0000 0000 0000 0010
Convert to decimal , The result is :2
Set negative integer -10 Move two places to the right
Original code :1000 0000 0000 0000 0000 0000 0000 1010
Then we have to calculate the complement :- Take the opposite , The sign bits remain the same , Do not participate in negation
1111 1111 1111 1111 1111 1111 1111 0101 - +1
1111 1111 1111 1111 1111 1111 1111 0110 - Displacement , Shift the highest position right to fill 1
1111 1111 1111 1111 1111 1111 1111 1101
Because here is the complement , The original code should be restored after the calculation , There are two forms : Take the opposite ,+1; perhaps -1 , Take the opposite :
- Take the opposite
1000 0000 0000 0000 0000 0000 0000 0010 - +1
1000 0000 0000 0000 0000 0000 0000 0011
Convert to decimal , The result is : -3
- Take the opposite , The sign bits remain the same , Do not participate in negation
边栏推荐
猜你喜欢

Session&Cookie&token

Easy to use shell shortcuts
![[day02] Introduction to data type conversion, operators and methods](/img/81/e2c49a4206e5d0d05308a1fc881626.png)
[day02] Introduction to data type conversion, operators and methods

【HCIP】重发布、重分布、重分发实验

你了解微信商户分账吗?
![[machine learning network] BP neural network and deep learning-6 deep neural networks (DNN)](/img/6a/02c76f5bd35b2d89e4f471b9b688f5.png)
[machine learning network] BP neural network and deep learning-6 deep neural networks (DNN)

第六章:云数据库

There are two solutions for the feign call header of microservices to be discarded (with source code)

Ribbon load balancing principle and some source codes

Head detached from origin/... Causes push failure
随机推荐
Chapter 6: cloud database
Spark practice case (upgraded version)
redux三大核心
Do you know about wechat merchant billing?
【C语言】递归详解汉诺塔问题
e.target与e.currentTarget的区别
地平线 旭日X3 PI (四) 板上运行(未写完)
微服务的feign调用header头被丢弃两种解决方案(附源码)
Using webmvcconfigurer to intercept interface requests is being enhanced (with source code)
【HCIP】重发布、重分布、重分发实验
【独立站建设】跨境电商出海开网店,首选这个网站建设!
Detailed explanation of TCP protocol knowledge
Shell的正则表达式入门、常规匹配、特殊字符:^、$、.、*、字符区间(中括号):[ ]、特殊字符:\、匹配手机号
sram、dram、sdram、ddr的区别和用途
Dino paper accuracy, and analyze the variant of its model structure & Detr
Px4 module design 12: high resolution timer design
结构型模式-桥接模式
The project parameters are made into configurable items, and the @configurationproperties annotation is used
Full revolutionary networks for semantic segmentation (FCN)
2022-07-26:以下go语言代码输出什么?A:5;B:hello;C:编译错误;D:运行错误。 package main import ( “fmt“ ) type integer in