[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

# Technical Reference: Base Operating System and Extensions, Volume 1

## powf, powl, or pow Subroutine

Computes power.

### Syntax

```#include <math.h>

float powf (x, y)
float x;
float y;

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

double pow (x, y)
double x, y;```

### Description

The powf, powl, and pow subroutines compute the value of x raised to the power y, x y. If x is negative, the application ensures that y is an integer value.

An application wishing to check for error situations should set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these subroutines. Upon return, if errno is nonzero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is nonzero, an error has occurred.

### Parameters

 x Specifies the value of the base. y Specifies the value of the exponent.

### Return Values

Upon successful completion, the pow, powf and powl subroutines return the value of x raised to the power y.

For finite values of x < 0, and finite non-integer values of y, a domain error occurs and a NaN is returned.

If the correct value would cause overflow, a range error occurs and the pow, powf, and powl subroutines return HUGE_VAL, HUGE_VALF, and HUGE_VALL, respectively.

If the correct value would cause underflow, and is not representable, a range error may occur, and 0.0 is returned.

If x or y is a NaN, a NaN is returned (unless specified elsewhere in this description).

For any value of y (including NaN), if x is +1, 1.0 is returned.

For any value of x (including NaN), if y is ±0, 1.0 is returned.

For any odd integer value of y>0, if x is ±0, ±0 is returned.

For y > 0 and not an odd integer, if x is ±0, +0 is returned.

If x is -1, and y is ±Inf, 1.0 is returned.

For |x<1, if y is -Inf, +Inf is returned.

For |x>1, if y is -Inf, +0 is returned.

For |x<1, if y is +Inf, +0 is returned.

For |x>1, if y is +Inf, +Inf is returned.

For y an odd integer < 0, if x is -Inf, -0 is returned.

For y < 0 and not an odd integer, if x is -Inf, +0 is returned.

For y an odd integer > 0, if x is -Inf, -Inf is returned.

For y > 0 and not an odd integer, if x is -Inf, +Inf is returned.

For y <0, if x is +Inf, +0 is returned.

For y >0, if x is +Inf, +Inf is returned.

For y an odd integer < 0, if x is ±0, a pole error occurs and ±HUGE_VAL, ±HUGE_VALF, and ±HUGE_VALL is returned for pow, powf, and powl, respectively.

For y < 0 and not an odd integer, if x is ±0, a pole error occurs and HUGE_VAL, HUGE_VALF and HUGE_VALL is returned for pow, powf, and powl, respectively.

If the correct value would cause underflow, and is representable, a range error may occur and the correct value is returned.

### Error Codes

When using the libm.a library:

 pow If the correct value overflows, the powsubroutine returns a HUGE_VAL value and sets errno to ERANGE. If the x parameter is negative and the y parameter is not an integer, the pow subroutine returns a NaNQ value and sets errno to EDOM. If x=0 and the y parameter is negative, the pow subroutine returns a HUGE_VAL value but does not modify errno. powl If the correct value overflows, the powlsubroutine returns a HUGE_VAL value and sets errno to ERANGE. If the x parameter is negative and the y parameter is not an integer, the powl subroutine returns a NaNQ value and sets errno to EDOM. If x=0 and the y parameter is negative, the powl subroutine returns a HUGE_VAL value but does not modify errno.

When using libmsaa.a(-lmsaa):

 pow If x=0 and the y parameter is not positive, or if the x parameter is negative and the y parameter is not an integer, the pow subroutine returns 0 and sets errno to EDOM. In these cases a message indicating DOMAIN error is output to standard error. When the correct value for the pow subroutine would overflow or underflow, the pow subroutine returns: ```+HUGE_VAL OR -HUGE_VAL OR 0``` When using either the libm.a library or the libsaa.a library: powl If the correct value overflows, powl returns HUGE_VAL and errno to ERANGE. If x is negative and y is not an integer, powl returns NaNQ and sets errno to EDOM. If x = zero and y is negative, powl returns a HUGE_VAL value but does not modify errno.

### Related Information

math.h in AIX 5L Version 5.2 Files Reference.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]