1 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
2 .TH "POW" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
5 pow, powf, powl \- power function
11 double pow(double\fP \fIx\fP\fB, double\fP \fIy\fP\fB);
13 float powf(float\fP \fIx\fP\fB, float\fP \fIy\fP\fB);
15 long double powl(long double\fP \fIx\fP\fB, long double\fP \fIy\fP\fB);
20 These functions shall compute the value of \fIx\fP raised to the power
21 \fIy\fP, \fIx**y\fP. If
22 \fIx\fP is negative, the application shall ensure that \fIy\fP is
25 An application wishing to check for error situations should set \fIerrno\fP
27 \fIfeclearexcept\fP(FE_ALL_EXCEPT) before calling these functions.
28 On return, if \fIerrno\fP is non-zero or
29 \fIfetestexcept\fP(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW)
30 is non-zero, an error has occurred.
33 Upon successful completion, these functions shall return the value
34 of \fIx\fP raised to the power \fIy\fP.
36 For finite values of \fIx\fP < 0, and finite non-integer values of
37 \fIy\fP, a domain error shall occur and \ either a NaN
38 (if representable), or an implementation-defined value shall be
41 If the correct value would cause overflow, a range error shall occur
42 and \fIpow\fP(), \fIpowf\fP(), and \fIpowl\fP() shall
43 return \(+-HUGE_VAL, \(+-HUGE_VALF, and \(+-HUGE_VALL, respectively,
44 with the same sign as the correct value of the
47 If the correct value would cause underflow, and is not representable,
48 a range error may occur, and \ either 0.0 (if
49 supported), or \ an implementation-defined value shall be
53 \fIx\fP or \fIy\fP is a NaN, a NaN shall be returned (unless specified
54 elsewhere in this description).
56 For any value of \fIy\fP (including NaN), if \fIx\fP is +1, 1.0 shall
59 For any value of \fIx\fP (including NaN), if \fIy\fP is \(+-0, 1.0
62 For any odd integer value of \fIy\fP > 0, if \fIx\fP is \(+-0, \(+-0
65 For \fIy\fP > 0 and not an odd integer, if \fIx\fP is \(+-0, +0 shall
68 If \fIx\fP is -1, and \fIy\fP is \(+-Inf, 1.0 shall be returned.
70 For |\fIx\fP| < 1, if \fIy\fP is -Inf, +Inf shall be returned.
72 For |\fIx\fP| > 1, if \fIy\fP is -Inf, +0 shall be returned.
74 For |\fIx\fP| < 1, if \fIy\fP is +Inf, +0 shall be returned.
76 For |\fIx\fP| > 1, if \fIy\fP is +Inf, +Inf shall be returned.
78 For \fIy\fP an odd integer < 0, if \fIx\fP is -Inf, -0 shall be returned.
80 For \fIy\fP < 0 and not an odd integer, if \fIx\fP is -Inf, +0 shall
83 For \fIy\fP an odd integer > 0, if \fIx\fP is -Inf, -Inf shall be
86 For \fIy\fP > 0 and not an odd integer, if \fIx\fP is -Inf, +Inf shall
89 For \fIy\fP < 0, if \fIx\fP is +Inf, +0 shall be returned.
91 For \fIy\fP > 0, if \fIx\fP is +Inf, +Inf shall be returned.
93 For \fIy\fP an odd integer < 0, if \fIx\fP is \(+-0, a pole error
94 shall occur and \(+-HUGE_VAL, \(+-HUGE_VALF,
95 and \(+-HUGE_VALL shall be returned for \fIpow\fP(), \fIpowf\fP(),
96 and \fIpowl\fP(), respectively.
98 For \fIy\fP < 0 and not an odd integer, if \fIx\fP is \(+-0, a pole
99 error shall occur and HUGE_VAL, HUGE_VALF, and
100 HUGE_VALL shall be returned for \fIpow\fP(), \fIpowf\fP(), and \fIpowl\fP(),
103 If the correct value would cause underflow, and is representable,
104 a range error may occur and the correct value shall be
108 These functions shall fail if:
111 The value of \fIx\fP is negative and \fIy\fP is a finite non-integer.
113 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
114 then \fIerrno\fP shall be set to [EDOM]. If the
115 integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero,
116 then the invalid floating-point exception shall be
120 The value of \fIx\fP is zero and \fIy\fP is negative.
122 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
123 then \fIerrno\fP shall be set to [ERANGE]. If the
124 integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero,
125 then the divide-by-zero floating-point exception shall be
129 The result overflows.
131 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
132 then \fIerrno\fP shall be set to [ERANGE]. If the
133 integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero,
134 then the overflow floating-point exception shall be
138 These functions may fail if:
141 The result underflows.
143 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
144 then \fIerrno\fP shall be set to [ERANGE]. If the
145 integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero,
146 then the underflow floating-point exception shall be
150 \fIThe following sections are informative.\fP
154 .SH APPLICATION USAGE
156 On error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling
157 & MATH_ERREXCEPT) are independent of
158 each other, but at least one of them must be non-zero.
162 .SH FUTURE DIRECTIONS
167 \fIexp\fP() , \fIfeclearexcept\fP() , \fIfetestexcept\fP() , \fIisnan\fP()
168 , the Base Definitions volume of
169 IEEE\ Std\ 1003.1-2001, Section 4.18, Treatment of Error Conditions
171 Mathematical Functions, \fI<math.h>\fP
173 Portions of this text are reprinted and reproduced in electronic form
174 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
175 -- Portable Operating System Interface (POSIX), The Open Group Base
176 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
177 Electrical and Electronics Engineers, Inc and The Open Group. In the
178 event of any discrepancy between this version and the original IEEE and
179 The Open Group Standard, the original IEEE and The Open Group Standard
180 is the referee document. The original Standard can be obtained online at
181 http://www.opengroup.org/unix/online.html .