CONV()

Overview

Converts the given numbers from the first base argument to the second base argument.

USAGE

CONV(expr, from_number_base, to_number_base)

Argument Name

Description

expr

The number to convert

from_number_base

The number base from which the number is to be converted

to_number_base

The number base to which the number is to be converted

DETAILS

CONV() is a mathematical function that converts the number specified as the first argument from a from_number_base to a to_number_base and returns the result.

Input values that contain non-decimal digits (0..10) must be specified as a string.

The "from" and "to" base arguments are integers that must be in the range of 2 to 36 (inclusive) or -36 to -2 (inclusive).

If the from_number_base is specified as a negative number, all input values are interpreted as unsigned, even if they are large enough to set the high bit in a 64-bit value.

If the to_number_base is specified as a negative number, positive and negative input values are differentiated by the standard prefixed minus sign (-) in front of negative values. If the to_number_base is specified as a positive number, then a negative input value is output as a positive value derived from its two's complement value.

A NULL is returned if any of the arguments are NULL or an invalid base is supplied.

SYNONYMS

SCHEMA

PARAMETERS

SKYSQL

PRIVILEGES

EXAMPLES

SELECT CONV(10, 10, 8);
+-----------------+
| CONV(10, 10, 8) |
+-----------------+
| 12              |
+-----------------+
SELECT CONV('b', 16, 10);
+-------------------+
| CONV('b', 16, 10) |
+-------------------+
| 11                |
+-------------------+
SELECT CONV(-123, 10, 32), CONV(-123, 10, -32);
+--------------------+---------------------+
| CONV(-123, 10, 32) | CONV(-123, 10, -32) |
+--------------------+---------------------+
| FVVVVVVVVVVS5      | -3R                 |
+--------------------+---------------------+
SET @big = 'FVVVVVVVVVVS5';
SELECT CONV(@big, 32, -10), CONV(@big, -32, -10);
+---------------------+----------------------+
| CONV(@big, 32, -10) | CONV(@big, -32, -10) |
+---------------------+----------------------+
| -123                | NULL                 |
+---------------------+----------------------+

ERROR HANDLING

FEATURE INTERACTION

RESPONSES

DIAGNOSIS

ISO 9075:2016

CHANGE HISTORY

Release Series

History

23.09

  • Present starting in MariaDB Xpand 23.09.1.

6.1

  • Present starting in MariaDB Xpand 6.1.0.

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.1

  • Present starting in MariaDB Xpand 6.1.0.

EXTERNAL REFERENCES