Guardian C Library Calls Reference Manual
pow
3-140 128833—Guardian TNS C Library Calls Reference Manual
Reference to Library Calls
pow
The pow function computes the value of its first argument raised to the power of its
second argument.
expr1
is an expression of type double.
expr2
is an expression of type double, specifying the power to which to raise expr1.
Return Value
is the value of expr1 raised to the expr2 power (that is, expr1expr2). If expr1 is zero
and expr2 is less than or equal to zero, or if expr1 is negative and expr2 is not an
integral value, pow returns -HUGE_VAL and sets errno to EDOM (a domain error).
In addition, pow returns HUGE_VAL if a positive overflow occurs, -HUGE_VAL if
a negative overflow occurs or zero if underflow occurs. In each of these cases, pow
also sets errno to ERANGE (a range error).
Example
This example prints “2.000000 to the power of 3.000000 is 8.000000.”:
#include <mathh>
#include <stdioh>
int main(void)
{
double r, x, y;
x = 2.0;
y = 3.0;
r = pow(x, y);
printf("%f to the power of %f is %f.", x, y, r);
}
#include <mathh>
double pow(double expr1, double expr2);