content_image/687401.jpg content_image/687402.jpg content_image/687403.jpg
<img src='content_image/687401.jpg'>

Example 3 . Rounding behavior for exact-value numbers is well-defined: 

Rounding behavior (for example, with the ROUND()  function) is independent of the implementation of the underlying C library, which means that results are consistent from platform to platform. 

•Rounding for exact-value columns ( DECIMAL  and integer) and exact-valued numbers uses the “round half away from zero”  rule. A value with a fractional part of .5 or greater is rounded away from zero to the nearest integer, as shown here: 

mysql> SELECT ROUND(2.5), ROUND(-2.5); 

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

•Rounding for floating-point values uses the C library, which on many systems uses the “round to nearest even”  rule. A value with a fractional part exactly half way between two integers is rounded to the nearest even integer: 

mysql> SELECT ROUND(2.5E0), ROUND(-2.5E0); 

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

Example 4 . In strict mode, inserting a value that is out of range for a column causes an error, rather than truncation to a legal value. 

When MySQL is not running in strict mode, truncation to a legal value occurs: 

mysql> SET sql_mode=’’; Query OK, 0 rows affected (0.00 sec) mysql> CREATE TABLE t (i TINYINT); Query OK, 0 rows affected (0.01 sec) mysql> INSERT INTO t SET i = 128; Query OK, 1 row affected, 1 warning (0.00 sec) mysql> SELECT i FROM t; +------+ | i | +------+ | 127 | +------+ 1 row in set (0.00 sec) 

However, an error occurs if strict mode is in effect: 

mysql> SET sql_mode=’STRICT_ALL_TABLES’; Query OK, 0 rows affected (0.00 sec) mysql> CREATE TABLE t (i TINYINT); Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO t SET i = 128; 

