forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com> Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
8.4 KiB
8.4 KiB
conv
This function is used to convert a number from from_base to to_base.
Syntax
conv(BIGINT num, INT from_base, INT to_base)
Parameters
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. |
Return Values
The return value is of the STRING type.
Example Code
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);
Parent topic: Mathematical Functions