I. Representation of IEEE 754 floating-point numbers
floating-point numbers are mathematically expressed :
sign: determines the positive or negative of the floating-point number
mantissa (significand): Binary decimal, range in [up] or [0,1]
Order Code (exponent): Weighted for floating-point numbers, with a weight of 2 for the power of E
single-precision floating-point number: in the single-precision floating point number, the symbol bit is encoded as 1-bit bits, the order code is 8-bit bits, and the mantissa is encoded as 23-bit bits;
double-precision floating-point number: in double-precision floating-point number, the symbol bit is encoded as 1-bit bits, the order code is 11-bit bits, and the mantissa is encoded as 52-bit bits;
second, floating-point code knowledge Reserve<1> Floating-point code shift notation:
The shift code is a constant on the basis of the truth value, which is called the bias (Bias), which is equivalent to moving several units on the x-axis; The shift code is defined as ;
the advantage of using the shift code : You can map the truth to a positive field, the shift code as an unsigned number, you can directly follow the comparison rules of unsigned integers to compare the size of the order.
<2> Normalization
In order to make full use of the significant digits of the mantissa, it is usually stipulated that the highest bit of the mantissa of the floating-point number needs to be a valid value, which is normalized for floating-point numbers.
With the normalized form of floating-point numbers, the absolute value of the mantissa of the floating-point number is 0.5 <= | m| < 1
third, IEEE 754 floating-point number encoding method
Depending on the order code, floating-point numbers can be encoded in 3 situations:
<1> normalized number:
1) Order code: The binary encoding of the order code is not all 0 and 1; Use the shift code to denote the value of the order code, the value of the order is E = E-bias, where Bias = 2^ (k-1)-1;
2) Mantissa code: The mantissa of the normalized number is encoded as a normalized representation of floating-point numbers, and the mantissa binary code is represented as;
The mantissa is defined as M = 1 + F, which is an implied expression that begins with 1
<2> Non-normalized number:
1) Decoding code: The order code of the binary code is all 0, in this case, the order value is E = 1–bias;
2) Mantissa code: The value of the mantissa m=f, does not contain the implied beginning of 1;
3) Use:
(1) Indicates a value of 0
(2) A number that represents an approximate value of 0
<3> Special Values:
1) Order Code: Order Code is all 1
2) mantissa encoding: The mantissa code is all 0 o'clock, indicating infinity, S = 0 for positive infinity, S=1 for negative infinity, and when the mantissa is not all 0 o'clock, the result value is Nan (not a number),
That means it's not a numeric value.
Iv. Properties of the IEEE 754 floating-point encoding
Take the 8-bit floating-point number as an example, where the order code is 4 bits, the mantissa is encoded as 3 bits,
<1> the size of the positive floating-point number is kept ascending by the dictionary order of the bit expression;
<2> there is a smooth transition between the non-normalized floating-point number and the normalized floating-point number, and the non-normalized floating-point number can be smoothly converted to the specification floating point number
IEEE 754 standard floating-point numbers