]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3p/pow.3p
Import of man-pages 1.70
[thirdparty/man-pages.git] / man3p / pow.3p
1 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
2 .TH "POW" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
3 .\" pow
4 .SH NAME
5 pow, powf, powl \- power function
6 .SH SYNOPSIS
7 .LP
8 \fB#include <math.h>
9 .br
10 .sp
11 double pow(double\fP \fIx\fP\fB, double\fP \fIy\fP\fB);
12 .br
13 float powf(float\fP \fIx\fP\fB, float\fP \fIy\fP\fB);
14 .br
15 long double powl(long double\fP \fIx\fP\fB, long double\fP \fIy\fP\fB);
16 .br
17 \fP
18 .SH DESCRIPTION
19 .LP
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
23 an integer value.
24 .LP
25 An application wishing to check for error situations should set \fIerrno\fP
26 to zero and call
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.
31 .SH RETURN VALUE
32 .LP
33 Upon successful completion, these functions shall return the value
34 of \fIx\fP raised to the power \fIy\fP.
35 .LP
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
39 returned.
40 .LP
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
45 function.
46 .LP
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
50 returned.
51 .LP
52 If
53 \fIx\fP or \fIy\fP is a NaN, a NaN shall be returned (unless specified
54 elsewhere in this description).
55 .LP
56 For any value of \fIy\fP (including NaN), if \fIx\fP is +1, 1.0 shall
57 be returned.
58 .LP
59 For any value of \fIx\fP (including NaN), if \fIy\fP is \(+-0, 1.0
60 shall be returned.
61 .LP
62 For any odd integer value of \fIy\fP > 0, if \fIx\fP is \(+-0, \(+-0
63 shall be returned.
64 .LP
65 For \fIy\fP > 0 and not an odd integer, if \fIx\fP is \(+-0, +0 shall
66 be returned.
67 .LP
68 If \fIx\fP is -1, and \fIy\fP is \(+-Inf, 1.0 shall be returned.
69 .LP
70 For |\fIx\fP| < 1, if \fIy\fP is -Inf, +Inf shall be returned.
71 .LP
72 For |\fIx\fP| > 1, if \fIy\fP is -Inf, +0 shall be returned.
73 .LP
74 For |\fIx\fP| < 1, if \fIy\fP is +Inf, +0 shall be returned.
75 .LP
76 For |\fIx\fP| > 1, if \fIy\fP is +Inf, +Inf shall be returned.
77 .LP
78 For \fIy\fP an odd integer < 0, if \fIx\fP is -Inf, -0 shall be returned.
79 .LP
80 For \fIy\fP < 0 and not an odd integer, if \fIx\fP is -Inf, +0 shall
81 be returned.
82 .LP
83 For \fIy\fP an odd integer > 0, if \fIx\fP is -Inf, -Inf shall be
84 returned.
85 .LP
86 For \fIy\fP > 0 and not an odd integer, if \fIx\fP is -Inf, +Inf shall
87 be returned.
88 .LP
89 For \fIy\fP < 0, if \fIx\fP is +Inf, +0 shall be returned.
90 .LP
91 For \fIy\fP > 0, if \fIx\fP is +Inf, +Inf shall be returned.
92 .LP
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.
97 .LP
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(),
101 respectively.
102 .LP
103 If the correct value would cause underflow, and is representable,
104 a range error may occur and the correct value shall be
105 returned.
106 .SH ERRORS
107 .LP
108 These functions shall fail if:
109 .TP 7
110 Domain\ Error
111 The value of \fIx\fP is negative and \fIy\fP is a finite non-integer.
112 .LP
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
117 raised.
118 .TP 7
119 Pole\ Error
120 The value of \fIx\fP is zero and \fIy\fP is negative.
121 .LP
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
126 raised.
127 .TP 7
128 Range\ Error
129 The result overflows.
130 .LP
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
135 raised.
136 .sp
137 .LP
138 These functions may fail if:
139 .TP 7
140 Range\ Error
141 The result underflows.
142 .LP
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
147 raised.
148 .sp
149 .LP
150 \fIThe following sections are informative.\fP
151 .SH EXAMPLES
152 .LP
153 None.
154 .SH APPLICATION USAGE
155 .LP
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.
159 .SH RATIONALE
160 .LP
161 None.
162 .SH FUTURE DIRECTIONS
163 .LP
164 None.
165 .SH SEE ALSO
166 .LP
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
170 for
171 Mathematical Functions, \fI<math.h>\fP
172 .SH COPYRIGHT
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 .