当前位置:网站首页>Original code, inverse code and complement code
Original code, inverse code and complement code
2022-06-26 13:42:00 【Tom looks at programming】
1. Original code
The original code is the absolute value of the sign bit plus the true value , That is to say, the symbol is represented by the first digit , The rest of the bits represent the value . For example, if it is 8 Bit binary :
[+1] primary = 0000 0001 [-1] primary = 1000 0001
The first bit is the sign bit . Because the first bit is the sign bit , therefore 8 The value range of bit binary number is :
[1111 1111 , 0111 1111]==>[-127 , 127]
2. Inverse code
The representation of the inverse code is :
- The inverse of a positive number is itself
- The inverse of a negative number is based on its original code , The sign bits remain the same , The rest of the bits are reversed .
[+1] = [00000001] primary = [00000001] back [-1] = [10000001] primary = [11111110] back
3. Complement code
The representation of complement is :
- The complement of a positive number is itself
- The complement of a negative number is based on its original code , The sign bits remain the same , The rest of you take the opposite , Last +1. ( That is, on the basis of the inverse code +1)
[+1] = [00000001] primary = [00000001] back = [00000001] repair [-1] = [10000001] primary = [11111110] back = [11111111] repair
The operation of complement :
One 、 Complement addition
[X+Y] repair = [X] repair + [Y] repair
example :X=+0110011,Y=-0101001, seek [X+Y] repair
[X] repair =00110011 [Y] repair =11010111
[X+Y] repair = [X] repair + [Y] repair = 00110011+11010111=00001010
notes : Because the bit length of the arithmetic unit in the computer is fixed , The highest carry generated in the above operation will be discarded , So the result is not 100001010, It is 00001010.
Two 、 Complement subtraction
[X-Y] repair = [X] repair - [Y] repair = [X] repair + [-Y] repair
among [-Y] Complement is called negative complement , The way to find the negative complement is : All bits of the original code of the absolute value of a negative number are reversed bit by bit ; And then add the whole number 1.
example :1+(-1) [ Decimal system ]
1 The original code of 00000001 Convert to complement :00000001
-1 The original code of 10000001 Convert to complement :11111111
1+(-1)=0
00000001+11111111=00000000
00000000 Convert to decimal to 0
0=0 So the calculation is correct .
3、 ... and 、 Complement multiplication
Set the multiplicand 【X】 repair =X0.X1X2……Xn-1, The multiplier 【Y】 repair =Y0.Y1Y2……Yn-1,
【X*Y】 repair =【X】 repair ×【Y】 repair , Multiplier ( Multiplier ) The complement of multiplication is equal to the multiplication of complement .
边栏推荐
- KITTI Detection dataset whose format is letf_ top_ right_ bottom to JDE normalied xc_ yc_ w_ h
- 7-2 the cubic root of a number
- Ring queue PHP
- Included angle of 3D vector
- Chapter 10 setting up structured logging (2)
- 7.Consul服务注册与发现
- imagecopymerge
- Electron official docs series: Contributing
- [how to connect the network] Chapter 1: the browser generates messages
- PHP非对称加密算法(RSA)加密机制设计
猜你喜欢

Electron official docs series: Get Started
![[how to connect the network] Chapter 2 (Part 1): establish a connection, transmit data, and disconnect](/img/e3/a666ba2f48e8edcc7db80503a6156d.png)
[how to connect the network] Chapter 2 (Part 1): establish a connection, transmit data, and disconnect

Select tag - uses the default text as a placeholder prompt but is not considered a valid value

ES基于Snapshot(快照)的数据备份和还原

Gurivat sprint Harbour Exchange listed: created “multiple first”, received 900 million yuan Investment from IDG capital

创建一个自己的跨域代理服务器

NVM installation tutorial

Wechat applet -picker component is repackaged and the disabled attribute is added -- above

Analysis of state transition diagram of Beifu NC axis

嵌入式virlog代码运行流程
随机推荐
古瑞瓦特冲刺港交所上市:创下“多个第一”,获IDG资本9亿元投资
古瑞瓦特沖刺港交所上市:創下“多個第一”,獲IDG資本9億元投資
Here document interaction free and expect automatic interaction
MySQL explanation (II)
What is the use of index aliases in ES
[how to connect the network] Chapter 1: the browser generates messages
Electron official docs series: Processes in Electron
Mysql database explanation (6)
imagecopymerge
Design of simple digital circuit traffic light
A primary multithreaded server model
【MySQL从入门到精通】【高级篇】(二)MySQL目录结构与表在文件系统中的表示
Detailed practical sharing, two hours of funny videos after work, earning more than 7000 a month
Wechat applet - bind and prevent event bubble catch
计算两点之间的距离(二维、三维)
MySQL数据库讲解(五)
Detailed introduction to shell script (4)
A few lines of code can realize complex excel import and export. This tool class is really powerful!
MySQL数据库讲解(四)
7-2 a Fu the thief