Upgrade 3CX to v18 and get it hosted free!

Asterisk func math

Author image

Synopsis:

Performs Mathematical Functions

Description:

MATH(<number1><op><number 2>[,<type_of_result>])

Perform calculation on number 1 to number 2. Valid ops are:
+,-,/,*,%,<,>,>=,<=,==and behave as their C equivalents.
<type_of_result> – wanted type of result:
f, float – float(default)
i, int – integer,
h, hex – hex,
c, char – char

Max. value: 2147483647 (signed long)

% is the modulo operator
int cuts of all decimals (it does not perform any rounding)

Notes

MATH() can only perform a single operation per MATH statement.

Return value

Returns the resulting string.

Example

exten => s,1,Set(i=${MATH(123%16,int)})
sets var i=11 (modulo)

See also


Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.