MySQL Tutorial/Math Numeric Functions/TRUNCATE
Содержание
SELECT TRUNCATE(545,-2);
mysql>
mysql>
mysql> SELECT TRUNCATE(545,-2);
+------------------+
| TRUNCATE(545,-2) |
+------------------+
| 500 |
+------------------+
1 row in set (0.00 sec)
TRUNCATE(10.28*100,0);
mysql>
mysql> SELECT TRUNCATE(10.28*100,0);
+-----------------------+
| TRUNCATE(10.28*100,0) |
+-----------------------+
| 1028 |
+-----------------------+
1 row in set (0.00 sec)
mysql>
TRUNCATE(122,-2);
mysql>
mysql> SELECT TRUNCATE(122,-2);
+------------------+
| TRUNCATE(122,-2) |
+------------------+
| 100 |
+------------------+
1 row in set (0.00 sec)
mysql>
TRUNCATE(1.999,0);
mysql>
mysql> SELECT TRUNCATE(1.999,0);
+-------------------+
| TRUNCATE(1.999,0) |
+-------------------+
| 1 |
+-------------------+
1 row in set (0.00 sec)
mysql>
TRUNCATE(-1.999,1);
mysql>
mysql> SELECT TRUNCATE(-1.999,1);
+--------------------+
| TRUNCATE(-1.999,1) |
+--------------------+
| -1.9 |
+--------------------+
1 row in set (0.00 sec)
mysql>
TRUNCATE(X,D) returns the number X, truncated to D decimal places.
If D is 0, the result has no decimal point or fractional part.
D can be negative to cause D digits left of the decimal point of the value X to become zero.
mysql>
mysql> SELECT TRUNCATE(1.223,1);
+-------------------+
| TRUNCATE(1.223,1) |
+-------------------+
| 1.2 |
+-------------------+
1 row in set (0.00 sec)
mysql>
mysql> SELECT TRUNCATE(1.999,1);
+-------------------+
| TRUNCATE(1.999,1) |
+-------------------+
| 1.9 |
+-------------------+
1 row in set (0.00 sec)
mysql>