Code shifting

Terms in computer field
Collection
zero Useful+1
zero
Shift code (also known as increase code or offset code) is usually used to indicate Floating point number Of Order code , which is expressed in the form of Complement Similar, except that the sign bit is "1" for positive numbers and "0" for positive numbers negative , the numeric part is the same as the complement.
Chinese name
Code shifting
Operation rules
Opposite order operation
Relation with complement
Sign bits are opposite to each other
Attention
The correction amount is 2En
Alias
Addend Offset code
Purpose
Guaranteed float Machine zero All 0

In the computer

Announce
edit
reason
When the order code is expressed by complement code, when the order code is infinitely small and underflow occurs, the order code becomes 0, and the value of this floating point number becomes 1.
In fact, this number is infinitely close to zero. Then we need to take the "- 0" value as Machine zero [1]
definition
Shift code (also called increase code or offset code) is usually used to represent the order code of floating point numbers. Its representation is similar to that of complement code, except that its sign bit uses "1" to represent a positive number, and "0" to represent a negative number. The numerical part is the same as that of complement code.
① Definition of code shifting : If the order code consists of 1-bit sign bit and n-bit numerical bit, then [X] shift =2 n-1 + X(-2 n-1 ≤X<2 n-1
For example: when n=5
When X=+3, then [X] shift =10011
When X=- 3, then [X] shift =01101 [2]
② The relationship between shift code and complement code : [X] shift And [X] repair The relation of is that the sign bits are opposite to each other (only the sign bits are different),
For example: X=+01011 [X] repair =01011 [X] shift =11011
X=-11011 [X] repair =10101 [X] shift =00101
③ Problems to be noticed in code shifting operation
◎ The result of the code shifting operation needs to be corrected by 2En, that is, the correct result of the code shifting form is obtained after the sign bit of the result is reversed.
◎ In the code shift representation, 0 has a unique code - 1000... 00. When 000... 00 appears (- 2En), it belongs to floating point underflow. [3]
Sign bit order code mantissa
Step 1 : Order difference: │Δ E │=| 1010-0110 |=0100
Step 2 : order matching: the order code of Y is small, and the mantissa of Y is shifted 4 bits to the right
[Y] Float change to 0 1 010 0000110 1101 Save temporarily
Step 3 : add mantissa, use double sign bit complement operation
00 1100110
+00 0000110
00 1101100
Step 4 : Standardization, meet the requirements of standardization
Step 5 : Rounding, 0 to 1
Therefore, the floating point number format of the final operation result is 0 1 010 1101101,
That is, X+Y=+0 1101101*210
Operation rules of floating point numbers
1. Operation steps of floating point addition and subtraction
Set two floating point numbers X=Mx ※ 2Ex Y=My ※ 2Ey
To achieve X ± Y, the following five steps are required:
① Opposite order operation : Align small steps with large steps
② Add or subtract mantissa
③ Normalization : The result of mantissa operation must become a normalized floating point number. For the complement mantissa of double sign bits, it must be
001 ×××××××× or 110 ××××××××
If the above form is not met, the left or right gauge shall be treated.
④ Rounding operation : The mantissa value moved out to the right is usually rounded off with the "0" and "1" rounding method when performing order alignment or right gauge operation to ensure accuracy.
⑤ Correctness of judgment results : Check whether the level code overflows
If the order code underflow (code shifting means 00... 0), set the result to machine 0;
If the rank code overflows (exceeds the maximum value indicated by the rank code), set the overflow flag.
Example:
Assume that X=0. 0110011 * 211, Y=0.1101101 * 2-10 (the numbers here are binary)?? Calculate X+Y;
Solution: [X] floating: 0 1 011 1100110
[Y] Floating: 0 0 110 1101101
2. Operation steps of floating point multiplication and division
① Order code operation : order code sum (multiplication) or order code difference (division)
That is, [Ex+Ey] shift=[Ex] shift+[Ey] supplement
[Ex - Ey] shift=[Ex] shift+[- Ey] supplement
② Mantissa processing of floating point numbers : Round off the result of mantissa multiplication and division in floating point number
Example:
X=0 .0110011*2E11,Y=0.1101101*2E-10
X ※ Y
Solution: [X] Floating: 0 1 010 1100110
[Y] Floating: 0 0 110 1101101
Step 1 : order code addition
[Ex+Ey] Move=[Ex] Move+[Ey] Supplement=1 010+1 110=1 000
1 000 is 0 represented by code shifting
Step 2 Original code The result of mantissa multiplication is:
0 10101101101110
Step 3 : normalization processing: the normalization requirements have been met, no left gauge is required, the mantissa remains unchanged, and the order code remains unchanged.
Step 4 : Rounding: correct by adding 1 according to rounding rules
So X ※ Y=0.1010111 ※ 2E+000 [1]

In biology

Announce
edit
In biology, code shifting refers to Gene mutation As a result, a single base is increased or decreased, and the coding is confused, which makes normal operation impossible complementary base pairing So as to change the biological characteristics. [3]