conv Function
Introduction
The conv function is used to convert a number from one base to another. It supports conversions between bases 2 and 36 and can handle both signed and unsigned numbers.
Syntax
Parameters
num:STRINGtype, representing the number to be converted. The number is expressed as a string, and its base is specified byfromBase.fromBase:INTEGERtype, representing the base of the source number. The value range is from 2 to 36.toBase:INTEGERtype, representing the target base. The value range is from 2 to 36.
Return Value
Returns a STRING type result, representing the converted number.
- If
fromBaseis less than 2 or greater than 36, or iftoBaseis less than 2 or greater than 36, the function returnsNULL. - If
toBaseis negative, the numbernumis interpreted as a signed number; otherwise, it is treated as an unsigned number.
Examples
Example 1: Binary to Decimal
Example 2: Hexadecimal to Decimal
Example 3: Decimal to Hexadecimal
