CONV(N,from_base,to_base)

Converts numbers between different number bases. Returns a string representation of the number * N*, converted from base

`from_base`

`to_base`

Returns `NULL`

if any argument is `NULL`

, or if the second or third argument are not in the allowed range.

The argument * N* is interpreted as an integer, but may be specified as an integer or a string. The minimum base is 2 and the maximum base is 36. If

`to_base`

`N`

`N`

`CONV()`

works with 64-bit precision.Some shortcuts for this function are also available: `BIN()`

, `OCT()`

, `HEX()`

, `UNHEX()`

. Also, MariaDB allows binary literal values and hexadecimal literal values.

SELECT CONV('a',16,2); +----------------+ | CONV('a',16,2) | +----------------+ | 1010 | +----------------+ SELECT CONV('6E',18,8); +-----------------+ | CONV('6E',18,8) | +-----------------+ | 172 | +-----------------+ SELECT CONV(-17,10,-18); +------------------+ | CONV(-17,10,-18) | +------------------+ | -H | +------------------+ SELECT CONV(12+'10'+'10'+0xa,10,10); +------------------------------+ | CONV(12+'10'+'10'+0xa,10,10) | +------------------------------+ | 42 | +------------------------------+

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.

© 2019 MariaDB

Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.

https://mariadb.com/kb/en/conv/