This function is used to convert a number from from_base to to_base.
conv(BIGINT num, INT from_base, INT to_base)
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
num |
Yes |
DOUBLE, BIGINT, DECIMAL, or STRING |
Number whose base needs to be converted The value can be a float, integer, or string. |
from_base |
Yes |
DOUBLE, BIGINT, DECIMAL, or STRING |
It represents the base from which the number is converted. The value can be a float, integer, or string. |
to_base |
Yes |
DOUBLE, BIGINT, DECIMAL, or STRING |
It represents the base to which the number is converted. The value can be a float, integer, or string. |
The return value is of the STRING type.
The value 8 is returned.
select conv('1000', 2, 10);
The value B is returned.
select conv('1011', 2, 16);
The value 703710 is returned.
select conv('ABCDE', 16, 10);
The value 27 is returned.
select conv(1000.123456, 3.123456, 10.123456);
The value 18446744073709551589 is returned.
select conv(-1000.123456, 3.123456, 10.123456);
The value NULL is returned.
select conv('1100', null, 10);