1POW(P) POSIX Programmer's Manual POW(P)
2
3
4
6 pow, powf, powl - power function
7
9 #include <math.h>
10
11 double pow(double x, double y);
12 float powf(float x, float y);
13 long double powl(long double x, long double y);
14
15
17 These functions shall compute the value of x raised to the power y,
18 x**y. If x is negative, the application shall ensure that y is an inte‐
19 ger value.
20
21 An application wishing to check for error situations should set errno
22 to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these
23 functions. On return, if errno is non-zero or fetestexcept(FE_INVALID
24 | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has
25 occurred.
26
28 Upon successful completion, these functions shall return the value of x
29 raised to the power y.
30
31 For finite values of x < 0, and finite non-integer values of y, a
32 domain error shall occur and either a NaN (if representable), or an
33 implementation-defined value shall be returned.
34
35 If the correct value would cause overflow, a range error shall occur
36 and pow(), powf(), and powl() shall return ±HUGE_VAL, ±HUGE_VALF, and
37 ±HUGE_VALL, respectively, with the same sign as the correct value of
38 the function.
39
40 If the correct value would cause underflow, and is not representable, a
41 range error may occur, and either 0.0 (if supported), or an imple‐
42 mentation-defined value shall be returned.
43
44 If x or y is a NaN, a NaN shall be returned (unless specified elsewhere
45 in this description).
46
47 For any value of y (including NaN), if x is +1, 1.0 shall be returned.
48
49 For any value of x (including NaN), if y is ±0, 1.0 shall be returned.
50
51 For any odd integer value of y > 0, if x is ±0, ±0 shall be returned.
52
53 For y > 0 and not an odd integer, if x is ±0, +0 shall be returned.
54
55 If x is -1, and y is ±Inf, 1.0 shall be returned.
56
57 For |x| < 1, if y is -Inf, +Inf shall be returned.
58
59 For |x| > 1, if y is -Inf, +0 shall be returned.
60
61 For |x| < 1, if y is +Inf, +0 shall be returned.
62
63 For |x| > 1, if y is +Inf, +Inf shall be returned.
64
65 For y an odd integer < 0, if x is -Inf, -0 shall be returned.
66
67 For y < 0 and not an odd integer, if x is -Inf, +0 shall be returned.
68
69 For y an odd integer > 0, if x is -Inf, -Inf shall be returned.
70
71 For y > 0 and not an odd integer, if x is -Inf, +Inf shall be returned.
72
73 For y < 0, if x is +Inf, +0 shall be returned.
74
75 For y > 0, if x is +Inf, +Inf shall be returned.
76
77 For y an odd integer < 0, if x is ±0, a pole error shall occur and
78 ±HUGE_VAL, ±HUGE_VALF, and ±HUGE_VALL shall be returned for pow(),
79 powf(), and powl(), respectively.
80
81 For y < 0 and not an odd integer, if x is ±0, a pole error shall occur
82 and HUGE_VAL, HUGE_VALF, and HUGE_VALL shall be returned for pow(),
83 powf(), and powl(), respectively.
84
85 If the correct value would cause underflow, and is representable, a
86 range error may occur and the correct value shall be returned.
87
89 These functions shall fail if:
90
91 Domain Error
92 The value of x is negative and y is a finite non-integer.
93
94 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
95 then errno shall be set to [EDOM]. If the integer expression
96 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the invalid
97 floating-point exception shall be raised.
98
99 Pole Error
100 The value of x is zero and y is negative.
101
102 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
103 then errno shall be set to [ERANGE]. If the integer expression
104 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the divide-by-
105 zero floating-point exception shall be raised.
106
107 Range Error
108 The result overflows.
109
110 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
111 then errno shall be set to [ERANGE]. If the integer expression
112 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the overflow
113 floating-point exception shall be raised.
114
115
116 These functions may fail if:
117
118 Range Error
119 The result underflows.
120
121 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
122 then errno shall be set to [ERANGE]. If the integer expression
123 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the underflow
124 floating-point exception shall be raised.
125
126
127 The following sections are informative.
128
130 None.
131
133 On error, the expressions (math_errhandling & MATH_ERRNO) and
134 (math_errhandling & MATH_ERREXCEPT) are independent of each other, but
135 at least one of them must be non-zero.
136
138 None.
139
141 None.
142
144 exp() , feclearexcept() , fetestexcept() , isnan() , the Base Defini‐
145 tions volume of IEEE Std 1003.1-2001, Section 4.18, Treatment of Error
146 Conditions for Mathematical Functions, <math.h>
147
149 Portions of this text are reprinted and reproduced in electronic form
150 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
151 -- Portable Operating System Interface (POSIX), The Open Group Base
152 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
153 Electrical and Electronics Engineers, Inc and The Open Group. In the
154 event of any discrepancy between this version and the original IEEE and
155 The Open Group Standard, the original IEEE and The Open Group Standard
156 is the referee document. The original Standard can be obtained online
157 at http://www.opengroup.org/unix/online.html .
158
159
160
161IEEE/The Open Group 2003 POW(P)