sign
Description
Syntax:
TINYINT sign(DOUBLE x)
This function returns the sign of x
. For negatives, zeros, and positives, it returns -1
, 0
and 1
, respectively.
Example
mysql> select sign(3);
+-----------+
| sign(3.0) |
+-----------+
| 1 |
+-----------+
mysql> select sign(0);
+-----------+
| sign(0.0) |
+-----------+
| 0 |
mysql> select sign(-10.0);
+-------------+
| sign(-10.0) |
+-------------+
| -1 |
+-------------+
1 row in set (0.01 sec)
Keywords
SIGN