In MySQL, floating-point numbers and fixed-points are used to represent decimals, and floating-point numbers include single-precision floating-point types (float) and double-precision floating-point types (double), with a fixed-point number of only decimal types. Both floating-point and fixed-point types can be represented by (M, N), where M is precision, which represents the total number of digits, and N is the scale that represents the number of decimal places.
(1) floating point and fixed point number: Floating point is the decimal point in the decimal position is not fixed, the point number refers to the decimal point in the position of the decimal is fixed
(2) Single-precision and double-precision: single-precision with 4 bytes to store, double-precision with 8 bytes to store, because of different storage bits, they can represent a different range of values, that is, the number of digits can be accurately represented is different.
Type name |
Description |
Storage requirements |
Signed Value Range |
Unsigned range of values |
FLOAT |
Single-precision floating-point number |
4 bytes |
-3.4028 ~-1.1754 |
0 and 1.1754 ~ 3.4028 |
DOUBLE |
Double-precision floating-point number |
8 bytes |
-1.7976 ~-2.2250 |
0 and 2.2250 ~ 1.7976 |
DECIMAL |
Compressed "strict" fixed-point number |
m+2 bytes |
Not fixed |
Not fixed |
MySQL floating-point type and fixed-point number type