When calculating a numeric value, an error is generated by changing a number from code rounding to SQL rounding for integer processing. The field is a varchar type, and the modified result is calculated with the previous result when the decimal bit is. 5 rounding carry, there is an error. For example 2.5, when the field type is a varchar or double type, the round function is used, the result is 2, and decimal is normal.
Execute sql: SELECT C_varchar,round (C_varchar), C_double,round (c_double), C_decimal,round (c_decimal) from round_test
Run Result: 2.5 2 2.50 2 2.50 3 Refer to the relevant information, see someone said adding a field value a decimal that does not affect the result, the value can be normal, test it, indeed.
Execute sql: SELECT C_varchar,round (c_varchar+0.000001), C_double,round (c_double+0.000001), C_decimal,round (C_decimal) from Round_test
operation Result:2.5 3 2.50 3 2.50 3 specific reasons, follow-up analysis ...
Round () rounding pit in MySQL