All pages
Powered by GitBook
1 of 1

Loading...

CONV

Convert numbers between bases. This function transforms a number from one numeric base system to another.

Syntax

Description

Converts numbers between different number bases. Returns a string representation of the number N, converted from base from_base to 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 62. 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.

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 is a negative number, N is regarded as a signed number. Otherwise,

Some shortcuts for this function are also available: , , , . Also, MariaDB allows literal values and literal values.

Examples

This page is licensed: GPLv2, originally from

CONV(N,from_base,to_base)
N
is treated as unsigned.
CONV()
works with 64-bit precision.
BIN()
OCT()
HEX()
UNHEX()
binary
hexadecimal
fill_help_tables.sql
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                           |
+------------------------------+