MySQL data type byte meaning
Float (m,d) 4-byte single-precision floating-point, 8-bit precision,m is the total number of decimal digits, andD is the number of digits after the decimal point
Double (m,d) 8-byte dual-precision floating-point, 16-bit precision
Float (7,4) can be displayed as -999.9999,MySQL is rounded when the value is saved , and if 999.00009 is inserted, the result is 999.0001
The parameter m stores the total length of the number,while D is different, affecting the precision, the number of digits after the decimal point.
For example, if a field is defined as float (5,3), if a number of 123.45678 is inserted, the actual database is 99.999, because the integer and decimal digits exceed the limit length of 5 to take the maximum value of the decimal place.
If you enter 1.45678, the database is stored as 1.457 after the decimal point, and the number is truncated to 457.
Note: Be sure to note the length of the number, determine the maximum value of the stored m and D precision values
Fixed-point number (decimal)
Numeric ranges depend on values of M and D
Decimal (M,D) m must be greater than or equal to D
Floating-point types hold approximate values in the database, while the fixed-point type stores the exact values in the database.
The parameter m is the maximum number (precision) of the fixed-point type number, the range is 0~65,
d the number of digits to the right of the decimal point, range 0~30, but not more than M.
The calculation of the fixed-point number can be accurate to 65 digits.
MySQL data type--floating point and fixed-point type