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