Principles of Computer Composition - Sequel to Operational Methods (Floating Point Number Representation)

floating point representation

Represent the valid digits and range of a number in a storage unit of the computer. This method of separately expressing precision is equivalent to the fact that the position of the decimal point of the number can be floating within a certain range depending on the scale factor, so it is called floating point representation.

In a computer, an arbitrary binary number N can be written as

N = 2^e.M

Among them , M is called the mantissa of the floating-point number , which is a pure decimal . e is the exponent of the scaling factor, called the exponent of the floating-point number , and is an integer .

M: Determining precision

E: the size of the number

Es

Em-1 ··· E1 E0

Ms

Mn-1 ··· M1M0

Order symbol (order code symbol)

exponent code

numeral

mantissa

Floating point normalization

Representation of floating point numbers

1.11 X 2^0 = 0.111 X 2^1 = 11.1 X 2^-1

Purpose of normalization

Maintain the uniqueness of the floating-point representation

Keep more significant figures and improve the accuracy of operations

Standardization requirements

1/R<=|mantissa|<1; R is the base number, such as 2, that is, greater than or equal to 1/2 and less than 1

Normalization

The mantissa is shifted to the left by n bits (the decimal point is shifted to the right), and the exponent is subtracted by n;

The mantissa is shifted to the right by n bits (the decimal point is shifted to the left), and the exponent is added by n.

Note: What is said here is that the value moves left and right, not the decimal point, remember " left minus right plus "

The mantissa is represented by the original code

The highest digit of the mantissa value is 1 , 0.1xxxx...

The mantissa is expressed in two's complement

Mantissa value bits and mantissa sign bits are reversed

just

0.1xxx

Positive number three yards in one

burden

1.0xxx

As far as negative numbers are concerned, the complement code is unattractive in form and turned into the original code, and the complement code is the original code, and the complement code of the complement code is the original code, and then it depends on the size

Data representation range of floating point numbers

N = M · 2^e

mantissa

negative minimum

negative maximum

positive minimum

positive maximum

exponent code

positive maximum

negative minimum

negative minimum

positive maximum

Overflow of floating-point numbers: exponent code overflow (during operation)

overflow : exponent greater than the maximum value of all representations; infinity

Underflow : the exponent is less than the minimum value of all representations; 0

Machine 0 : the mantissa is 0, or the exponent is less than the minimum value that can be represented

IEEE754 standard representation of 32-bit floating-point numbers

Numeral S

code E

Mantissa M

The first digit takes the value 0/1, the second position is the 8-bit exponent code containing the exponent, and the third is the 32-bit mantissa: value

Number symbol S: represents the symbol of the floating point number, occupying 1 bit , 0——positive number, 1——negative number

Mantissa M: 23 bits, original code pure decimal representation, the decimal point is at the front of the mantissa field;

Due to the requirements of the original code representation, the highest value bit is always 1, because the highest value bit (1) is hidden in this standard, and the actual value bit of the mantissa is 1.M;

The highest value of the mantissa M is 1, the advantage: the accuracy is increased, here 1.M is the value

Expansion code E: 8 bits, expressed by shifting the offset value, adding 127 to the true value;

Shift 1237 codes, that is, E = e+127, and the 8-bit binary number of E is the code for shifting 127 codes;

The truth value of a normalized 32-bit floating-point number x is expressed as

x = (-1)^S X (1.M) X 2^(E-127) e = E-127

Guess you like

Origin blog.csdn.net/qq_61897141/article/details/129210231