pow Functions

Description

Calculate x raised to the power of y.

#include <math.h>

double pow( double x, double y );

long double _powl( long double x, long double y );

x Number to be raised  
y Power of x  

Remarks

The pow and _powl functions compute x raised to the power of y.

The _powl function is the 80-bit counterpart, and it uses an 80-bit, 10-byte coprocessor form of arguments and return values. See the reference page on the long double functions for more details on this data type.

Return Value

The pow and _powl functions return the value of xy. If x is not 0.0 and y is 0.0, pow and _powl return the value 1. If x is 0.0 and y is negative, pow and _powl set errno to EDOM and return 0.0. If both x and y are 0.0, or if x is negative and y is not an integer, the function prints a _DOMAIN error message to stderr, sets errno to EDOM, and returns 0.0. If an overflow results, the function sets errno to ERANGE and returns ±HUGE_VAL. No message is printed on overflow or underflow.

The pow function does not recognize integral floating-point values greater than 264, such as 1.0E100.

Compatibility

pow

Standards:ANSI, UNIX

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:DOS32X

_powl

Standards:None

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:None

See Also

exp, log functions, sqrt

Example

/* POW.C */

#include <math.h>

#include <stdio.h>

void main( void )

{

double x = 2.0, y = 3.0, z;

z = pow( x, y );

printf( “%.1f to the power of %.1f is %.1f\n”, x, y, z );

}

Output

2.0 to the power of 3.0 is 8.0