Skip to main content

conv (Function)

This function converts a from the fromBase base to the toBase base.

Syntax

<STRING> math:conv(<STRING> a, <INT> from.base, <INT> to.base)

Query Parameters

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
aThe value whose base should be changed. Input should be given as a String.STRINGNoYes
from.baseThe source base of the input parameter a.INTNoYes
to.baseThe target base that the input parameter a should be converted into.INTNoYes

Example 1

CREATE STREAM InValueStream (inValue string,fromBase int,toBase int);

insert into OutMediationStream
select math:conv(inValue,fromBase,toBase) as convertedValue
from InValueStrea;

If the inValue in the input stream is given, and the base in which it currently resides in and the base to which it should be converted to is specified, then the function converts it into a string in the target base and directs it to the output stream, OutMediationStream. For example, conv("7f", 16, 10) returns "127".