MySQL Tutorial/Math Numeric Functions/CONV — различия между версиями

Материал из SQL эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 13:44, 26 мая 2010

CONV(N,10,16).

mysql>
mysql>
mysql> select CONV(10,10,16);
+----------------+
| CONV(10,10,16) |
+----------------+
| A              |
+----------------+
1 row in set (0.00 sec)
mysql>


CONV(N,10,2)

mysql> select CONV(100,10,2);
+----------------+
| CONV(100,10,2) |
+----------------+
| 1100100        |
+----------------+
1 row in set (0.01 sec)
mysql>


CONV(N,10,8)

mysql>
mysql> select CONV(256,10,8);
+----------------+
| CONV(256,10,8) |
+----------------+
| 400            |
+----------------+
1 row in set (0.00 sec)
mysql>


CONV(N,from_base,to_base): Converts numbers between different number bases

Returns NULL if any argument is NULL.

The minimum base is 2.

The maximum base is 36.

If to_base is a negative number, N is regarded as a signed number.

Otherwise, N is treated as unsigned.

CONV() works with 64-bit precision.



mysql>
mysql> SELECT CONV("a",16,2);
+----------------+
| CONV("a",16,2) |
+----------------+
| 1010           |
+----------------+
1 row in set (0.00 sec)
mysql>
mysql>


SELECT CONV(0xa,10,10);

mysql>
mysql> SELECT CONV(0xa,10,10);
+-----------------+
| CONV(0xa,10,10) |
+-----------------+
| 0               |
+-----------------+
1 row in set (0.00 sec)
mysql>


SELECT CONV("10",10,10);

mysql>
mysql>
mysql>
mysql> SELECT CONV("10",10,10);
+------------------+
| CONV("10",10,10) |
+------------------+
| 10               |
+------------------+
1 row in set (0.01 sec)
mysql>


SELECT CONV(-17,10,-18);

mysql>
mysql>
mysql> SELECT CONV(-17,10,-18);
+------------------+
| CONV(-17,10,-18) |
+------------------+
| -H               |
+------------------+
1 row in set (0.00 sec)
mysql>