6. Draw the structure of floating point numbers
The structure of floating point numbers mainly consists of the following parts:
- Sign bit : used to represent the sign of a floating point number, 0 represents positive, 1 represents negative.
- Exponent bit : used to represent the size of a floating point number, 0 represents 1, 1 represents 2, and so on.
- Mantissa bit : used to represent the specific value of a floating point number. The mantissa bit is usually expressed using scientific notation.
The following is the structure diagram of floating point numbers:
+--------+------------+----------------+
| 符号位 | 指数位 | 尾数位 |
+--------+------------+----------------+
sign bit
The sign bit is located at the highest bit of a floating point number and is used to indicate the sign of a floating point number. 0 means positive, 1 means negative.
Exponent bit
The exponent bit is located after the sign bit and is used to represent the size of the floating point number. The exponent bit is usually represented using 2's complement.
mantissa digits
The mantissa bit is located after the exponent bit and is used to represent the specific value of a floating point number. The mantissa digits are usually represented using scientific notation.
Representation of floating point numbers
Floating point numbers can be represented using scientific notation. Scientific notation is a convenient way to represent a decimal by dividing it into two parts: the exponent and the mantissa .
The exponent part represents the number of decimal places, and the mantissa part represents the specific value of the decimal.
For example, the floating point number 1.234e-03 can be represented as:
1.234 * 10^(-3)