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);

@info(name = 'convertBaseValue')
INSERT INTO OutMediationStream
SELECT math:conv(inValue, fromBase, toBase) AS convertedValue
FROM InValueStream;

The query takes the inValue, fromBase, and toBase from the input stream InValueStream. The math:conv() function is used to convert the inValue from its current base fromBase to the target base toBase. The result is directed to the output stream OutMediationStream. For example, when inValue is "7f", fromBase is 16, and toBase is 10, the convertedValue returned is "127".