MATH Module Daniel-Constantin Mierla Edited by Daniel-Constantin Mierla Copyright © 2023 asipto.com __________________________________________________________________ Table of Contents 1. Admin Guide 1. Overview 2. Dependencies 2.1. Kamailio Modules 2.2. External Libraries or Applications 3. Functions 3.1. pow(base, power, res) 3.2. math_logN(x, res) 3.3. math_log2(x, res) 3.4. math_log10(x, res) 3.5. math_sqrt(x, res) List of Examples 1.1. math_pow usage 1.2. math_logN usage 1.3. math_log2 usage 1.4. math_log10 usage 1.5. math_sqrt usage Chapter 1. Admin Guide Table of Contents 1. Overview 2. Dependencies 2.1. Kamailio Modules 2.2. External Libraries or Applications 3. Functions 3.1. pow(base, power, res) 3.2. math_logN(x, res) 3.3. math_log2(x, res) 3.4. math_log10(x, res) 3.5. math_sqrt(x, res) 1. Overview This module provides a collection of functions for math operations. Note that the result values are casted to intger (long value), being the type supported by the config variables. 2. Dependencies 2.1. Kamailio Modules 2.2. External Libraries or Applications 2.1. Kamailio Modules The following modules must be loaded before this module: * none 2.2. External Libraries or Applications The following libraries or applications must be installed before running Kamailio with this module loaded: * none 3. Functions 3.1. pow(base, power, res) 3.2. math_logN(x, res) 3.3. math_log2(x, res) 3.4. math_log10(x, res) 3.5. math_sqrt(x, res) 3.1. pow(base, power, res) The exponentiation function, computing the base raised to power, storing in res. This function can be used from ANY_ROUTE. Example 1.1. math_pow usage ... math_pow("2", "10", "$var(res)"); $var(base) = 2; $var(power) = 10; math_pow("$var(base)", "$var(power)", "$var(res)"); ... 3.2. math_logN(x, res) The function computes the natural logarithm of x and stores the result in res. This function can be used from ANY_ROUTE. Example 1.2. math_logN usage ... math_logN("10", "$var(res)"); $var(x) = 10; math_logN("$var(x)", "$var(res)"); ... 3.3. math_log2(x, res) The function computes the base-2 logarithm of x and stores the result in res. This function can be used from ANY_ROUTE. Example 1.3. math_log2 usage ... math_log2("16", "$var(res)"); $var(x) = 16; math_log2("$var(x)", "$var(res)"); ... 3.4. math_log10(x, res) The function computes the base-10 logarithm of x and stores the result in res. This function can be used from ANY_ROUTE. Example 1.4. math_log10 usage ... math_log10("100", "$var(res)"); $var(x) = 100; math_log10("$var(x)", "$var(res)"); ... 3.5. math_sqrt(x, res) The function computes the square root of x and stores the result in res. This function can be used from ANY_ROUTE. Example 1.5. math_sqrt usage ... math_sqrt("16", "$var(res)"); $var(x) = 16; math_sqrt("$var(x)", "$var(res)"); ...