当前位置:网站首页>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 .
边栏推荐
- VTK 圆柱体的生成与渲染
- Echart stack histogram: add white spacing effect setting between color blocks
- C language: Exercise 2
- A collection of common tools for making we media videos
- Es snapshot based data backup and restore
- Reflect the technical depth (unable to speed up)
- 【Proteus仿真】Arduino UNO按键启停 + PWM 调速控制直流电机转速
- POJ 3070 Fibonacci
- Basic type of typescript
- HW蓝队溯源流程详细整理
猜你喜欢
![[how to connect the network] Chapter 2 (next): receiving a network packet](/img/f5/33e1fd8636fcc80430b3860d069866.png)
[how to connect the network] Chapter 2 (next): receiving a network packet
![[MySQL from introduction to mastery] [advanced part] (II) representation of MySQL directory structure and tables in the file system](/img/03/a1885e4740bbfdbdee2446e3dd81d0.png)
[MySQL from introduction to mastery] [advanced part] (II) representation of MySQL directory structure and tables in the file system

MySQL explanation (II)

网络远程访问的方式使用树莓派

ES基於Snapshot(快照)的數據備份和還原

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

Ring queue PHP

awk工具

NVM installation tutorial

7.Consul服务注册与发现
随机推荐
There are many contents in the widget, so it is a good scheme to support scrolling
Mysql database explanation (IV)
Basic type of typescript
What is the use of index aliases in ES
Nlp-d60-nlp competition D29
Taishan Office Technology Lecture: four cases of using bold font
VTK 圆柱体的生成与渲染
Wechat applet -picker component is repackaged and the disabled attribute is added -- above
泰山OFFICE技术讲座:使用字体粗体的四种情形
H5视频自动播放和循环播放
Input text to automatically generate images. It's fun!
Beifu twincat3 can read and write CSV and txt files
Wechat applet -picker component is repackaged and the disabled attribute is added -- below
Electron official docs series: Processes in Electron
[how to connect the network] Chapter 1: the browser generates messages
MediaPipe手势(Hands)
Thinking caused by the error < note: candidate expectations 1 argument, 0 provided >
Common faults of MySQL database - forgetting database password
2021-10-09
Hdu1724[Simpson formula for integral]ellipse