O'Reilly logo

Asterisk: The Future of Telephony by Leif Madsen, Jared Smith, Jim Van Meggelen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Math() — Performs mathematical operations and returns the result

Synopsis

    Math(returnvar,number1 operator number2)

Performs a floating-point calculation on number1 to number2, and assigns the result to the variable named returnvar. Valid operators are +, -, /, *, %, <, >, >=, <=, and ==, and they behave as their C equivalents.

Always returns 0.

    ; add two numbers, and say the result
    exten => 123,1,Math(SUM,2+2)
    exten => 123,2,SayNumber(${SUM})

    ; subtract two numbers, and say the difference
    exten => 124,1,Math(DIFFERENCE,5-3)
    exten => 124,2,SayNumber(${DIFFERENCE})

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required