content_image/830586.jpg content_image/830587.jpg
mysql> SELECT ROUND(1.298, 1); -> 1.3 mysql> SELECT ROUND(1.298, 0); -> 1 mysql> SELECT ROUND(23.298, -1); -> 20 mysql> SELECT ROUND(.12345678901234567890123456789012345, 35); -> 0.123456789012345678901234567890 

The return value has the same type as the first argument (assuming that it is integer, double, or decimal). This means that for an integer argument, the result is an integer (no decimal places): 

mysql> SELECT ROUND(150.000,2), ROUND(150,2); 

<img src='content_image/830586.jpg'>

ROUND()  uses the following rules depending on the type of the first argument: 

•For exact-value numbers, ROUND()  uses the “round half away from zero”  or “round toward nearest” rule: A value with a fractional part of .5 or greater is rounded up to the next integer if positive or down to the next integer if negative. (In other words, it is rounded away from zero.) A value with a fractional part less than .5 is rounded down to the next integer if positive or up to the next integer if negative. 

•For approximate-value numbers, the result depends on the C library. On many systems, this means that ROUND()  uses the “round to nearest even”  rule: A value with a fractional part exactly halfway between two integers is rounded to the nearest even integer. 

The following example shows how rounding differs for exact and approximate values: 

mysql> SELECT ROUND(2.5), ROUND(25E-1); 

<img src='content_image/830587.jpg'>

For more information, see Section 12.25, “Precision Math” . 

In MySQL 8.0.21 and later, the data type returned by ROUND()  (and TRUNCATE() ) is determined according to the rules listed here: 

•When the first argument is of any integer type, the return type is always BIGINT . 

•When the first argument is of any floating-point type or of any non-numeric type, the return type is always DOUBLE . 

•When the first argument is a DECIMAL  value, the return type is also DECIMAL . 

•The type attributes for the return value are also copied from the first argument, except in the case of DECIMAL , when the second argument is a constant value. 

When the desired number of decimal places is less than the scale of the argument, the scale and the precision of the result are adjusted accordingly. 

In addition, for ROUND()  (but not for the TRUNCATE()  function), the precision is extended by one place to accomodate rounding that increases the number of significant digits. If the second argument is negative, the return type is adjusted such that its scale is 0, with a corresponding precision. For 

