Download Tutorial C Files H Files

dg_pow

This function calculate the power of a number by n.

Usage

double dg_fpow(double number, int pow);

Example

double dg_fpow(0.567, 5);

Source code

double dg_fpow(double number, int pow)
{
    double result = number;

    if (pow == 0)
        return 1;
    if (pow > 0)
        for (int i = 1; i < pow; i++)
            result *= number;
    else
        result = number / dg_pow(number, 1 - pow);
    return result;
}