Because when you created the table, you specified f3 as float(6,2), so what do these 6 and 2 mean? 6 is the total number of digits. 2 means only 2 digits are retained after the decimal point. So it will be displayed as 9999.99, which is a total of 6 9s, and there are 2 digits after the decimal
It is recommended to use decimal, especially when it comes to money issues. In mysql, float and double (or real) are floating point numbers, and decimal (or numberic) is a fixed point number.
The advantage of floating-point numbers over fixed-point numbers is that when the length is certain, floating-point numbers can represent a larger data range; its disadvantage is that it can cause accuracy problems.
In future applications of floating-point numbers and fixed-point numbers, everyone should remember the following points:
1. There is an error problem in floating point numbers;
2. Accuracy-sensitive data such as currencies should be represented or stored in fixed-point numbers;
3. In programming, if floating point numbers are used, special attention should be paid to error issues and try to avoid floating point comparisons;
4. Pay attention to the handling of some special values in floating point numbers. You can check out this http://blog.csdn.net/lingmao5...
Because when you created the table, you specified f3 as float(6,2), so what do these 6 and 2 mean?
6 is the total number of digits. 2 means only 2 digits are retained after the decimal point. So it will be displayed as 9999.99, which is a total of 6 9s, and there are 2 digits after the decimal
It is recommended to use decimal, especially when it comes to money issues. In mysql, float and double (or real) are floating point numbers, and decimal (or numberic) is a fixed point number.
The advantage of floating-point numbers over fixed-point numbers is that when the length is certain, floating-point numbers can represent a larger data range; its disadvantage is that it can cause accuracy problems.
In future applications of floating-point numbers and fixed-point numbers, everyone should remember the following points:
1. There is an error problem in floating point numbers;
2. Accuracy-sensitive data such as currencies should be represented or stored in fixed-point numbers;
3. In programming, if floating point numbers are used, special attention should be paid to error issues and try to avoid floating point comparisons;
4. Pay attention to the handling of some special values in floating point numbers.
You can check out this http://blog.csdn.net/lingmao5...
float(m,d)
In, m represents the total number of digits, d represents the number of digits to the right of the decimal pointDisplayed as follows:
Explanation:
Not specified
m,d
: Take the value according to the range of float and doubleSpecify
. If it exceeds, it will be rounded. If it does not exceed, it will be supplemented with 0m,d
: 按照m,d
: Take it according to the value of