# &adminguide;

## 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.

## Dependencies

### &kamailio; Modules

The following modules must be loaded before this module:

- none

### External Libraries or Applications

The following libraries or applications must be installed before running &kamailio; with this module loaded:

- none

## Functions

### `pow(base, power, res)`

The exponentiation function, computing the base raised to power, storing in res.

This function can be used from ANY_ROUTE.

#### `math_pow` usage

    ...
        math_pow("2", "10", "$var(res)");
        $var(base) = 2;
        $var(power) = 10;
        math_pow("$var(base)", "$var(power)", "$var(res)");
    ...

### `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.

#### `math_logN` usage

    ...
        math_logN("10", "$var(res)");
        $var(x) = 10;
        math_logN("$var(x)", "$var(res)");
    ...

### `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.

#### `math_log2` usage

    ...
        math_log2("16", "$var(res)");
        $var(x) = 16;
        math_log2("$var(x)", "$var(res)");
    ...

### `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.

#### `math_log10` usage

    ...
        math_log10("100", "$var(res)");
        $var(x) = 100;
        math_log10("$var(x)", "$var(res)");
    ...

### `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.

#### `math_sqrt` usage

    ...
        math_sqrt("16", "$var(res)");
        $var(x) = 16;
        math_sqrt("$var(x)", "$var(res)");
    ...