Article directory
Representation N = S * 2 E
Any binary number N can be expressed as: N = S * 2 E
That is: floating point number = mantissa * 2 -order code
As shown below:
Catalog E
E is the exponent code of the number N , and 2 is the base of the exponent code (R, usually 2, 8, 16),
which is a binary integer.
It indicates the position of the decimal point in the data and determines the size range of the floating point number.
framecode
frameshift
For positive numbers, the sign bit is "1" and the remaining bits remain unchanged. For
example, the exponent code of +1110001 is 11110001For negative numbers, the sign bit is "0", the remaining bits are inverted, and "1" is added at the end (the sign bit is 0 based on the complement code).
For example, the complement code of –1110001 is 1001111, and the exponent code is 0000111.
Mantissa S
S is the mantissa of the number N.
It is a binary decimal (fixed-point decimal form),
which determines the representation accuracy, that is, the number of significant digits.
The mantissa is one's complement
complement
For positive numbers, the complement is itself.
For example, the complement of +1110001 is 011110001.For negative numbers, the sign bit is 1, and the remainder is inverted and plus one.
For example, the complement of –1110001 is 1001111.
data range
Represented on the number axis as shown below
example
Substitute the exponent and mantissa into the above formula to calculate
Example 1
Floating point representation, 1-digit exponent, 2-digit exponent, 1-digit tail sign, 4-digit mantissa, the case where the mantissa is not standardized is also taken into account, the range that can be expressed: -2 3 ~ ( 1 - 2 -4 ) * 2 3
Example 2
Floating point representation, 1-bit exponent, 6-bit exponent, 1-bit tail sign, 8-bit mantissa, the case where the mantissa is not standardized is also taken into account, the representable range: -2 63 ~ ( 1 - 2 -8 ) * 2 63
Example 3
The floating-point number representation method is the same as Example 2. The closest negative number it can represent to 0 is: -2 -72The negative number closest to 0 is the largest negative number.
From the above formula, it can be seen that the exponent code = 6 and the mantissa = 8
are calculated by the formula:
-2 exponent code = -2 6 = -64
-2 -mantissa = -2 -8
The largest Negative numbers are: -2 -8 X 2 -64 = -2 -72