Computes power.
The powf, powl, pow, powd32, powd64, and powd128 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.
Item | Description |
---|---|
x | Specifies the value of the base. |
y | Specifies the value of the exponent. |
Upon successful completion, the pow, powf, powl, powd32, powd64, and powd128 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, powl, powd32, powd64, and powd128 subroutines return HUGE_VAL, HUGE_VALF, HUGE_VALL, HUGE_VAL_D32, HUGE_VAL_D64, and HUGE_VAL_D128 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, ±HUGE_VALL, ±HUGE_VAL_D32, ±HUGE_VAL_D64, and ±HUGE_VAL_D128 is returned for pow, powf, powl, powd32, powd64, and powd128 respectively.
For y < 0 and not an odd integer, if x is ±0, a pole error occurs and HUGE_VAL, HUGE_VALF, HUGE_VALL, HUGE_VAL_D32, HUGE_VAL_D64, and HUGE_VAL_D128 is returned for pow, powf, powl, powd32, powd64, and powd128 respectively.
If the correct value would cause underflow, and is representable, a range error may occur and the correct value is returned.
When using the libm.a library:
Item | Description |
---|---|
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):
Item | Description |
---|---|
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:
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. |