Home  >  Article  >  Database  >  MySQL数字的进制转换(conv的使用)_MySQL

MySQL数字的进制转换(conv的使用)_MySQL

WBOY
WBOYOriginal
2016-06-01 13:43:261184browse

bitsCN.com MySQL数字的进制转换(conv的使用)
CONV(N,from_base,to_base)
在不同的数字基数之间转换数字。将数字 N 从from_base 转换到 to_base,并以字符串形式返回。如果任何一个参数为 NULL,那么返回值也为 NULL。参数 N 被解释为是一个整数,但是也可以被指定为一个整数或一个字符串。最小基为 2,最大基为 36。如果 to_base 是一个负值,N 将被看作为是一个有符号数字。否则,N 被视为是无符号的。CONV 以 64 位精度工作。
 
mysql> select conv(100,10,2);
+----------------+
| conv(100,10,2) |
+----------------+
| 1100100        |
+----------------+
1 row in set (0.00 sec)
mysql> select conv(100,10,16);
+-----------------+
| conv(100,10,16) |
+-----------------+
| 64              |
+-----------------+
1 row in set (0.00 sec)
mysql>


作者 xyaxlz bitsCN.com

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn