1pow(3M) Mathematical Library Functions pow(3M)
2
3
4
6 pow, powf, powl - power function
7
9 c99 [ flag... ] file... -lm [ library... ]
10 #include <math.h>
11
12 double pow(double x, double y);
13
14
15 float powf(float x, float y);
16
17
18 long double powl(long double x, long double y);
19
20
21 cc [ flag... ] file... -lm [ library... ]
22 #include <math.h>
23
24 double pow(double x, double y);
25
26
27 float powf(float x, float y);
28
29
30 long double powl(long double x, long double y);
31
32
34 These functions compute the value of x raised to the power y, x^y>. If
35 x is negative, y must be an integer value.
36
38 Upon successful completion, these functions return the value of x
39 raised to the power y.
40
41
42 For finite values of x < 0, and finite non-integer values of y, a
43 domain error occurs and either a NaN (if representable), or an imple‐
44 mentation-defined value is returned.
45
46
47 If the correct value would cause overflow, a range error occurs and
48 pow(), powf(), and powl() return HUGE_VAL, HUGE_VALF, and HUGE_VALL,
49 respectively.
50
51
52 If x or y is a NaN, a NaN is returned unless:
53
54 o If x is +1 and y is NaN and the application was compiled
55 with the c99 compiler driver and is therefore SUSv3-conform‐
56 ing (see standards(5)), 1.0 is returned.
57
58 o For any value of x (including NaN), if y is +0, 1.0 is
59 returned.
60
61
62 For any odd integer value of y > 0, if x is ±0, ±0 is returned.
63
64
65 For y > 0 and not an odd integer, if x is ±0, +0 is returned.
66
67
68 If x is ±1 and y is ±Inf, and the application was compiled with the cc
69 compiler driver, NaN is returned. If, however, the application was com‐
70 piled with the c99 compiler driver and is therefore SUSv3-conforming
71 (seestandards(5)), 1.0 is returned.
72
73
74 For |x| < 1, if y is −Inf, +Inf is returned.
75
76
77 For |x| > 1, if y is −Inf, +0 is returned.
78
79
80 For |x| < 1, if y is +Inf, +0 is returned.
81
82
83 For |x| > 1, if y is +Inf, +Inf is returned.
84
85
86 For y an odd integer < 0, if x is −Inf, −0 is returned.
87
88
89 For y < 0 and not an odd integer, if x is −Inf, +0 is returned.
90
91
92 For y an odd integer > 0, if x is −Inf, −Inf is returned.
93
94
95 For y > 0 and not an odd integer, if x is −Inf, +Inf is returned.
96
97
98 For y < 0, if x is +Inf, +0 is returned.
99
100
101 For y > 0, if x is +Inf, +Inf is returned.
102
103
104 For y an odd integer < 0, if x is ±0, a pole error occurs and
105 ±HUGE_VAL, ±HUGE_VALF, and ±HUGE_VALL are returned for pow(), powf(),
106 and powl(), respectively.
107
108
109 For y < 0 and not an odd integer, if x is ±0, a pole error occurs and
110 HUGE_VAL, HUGE_VALF, and HUGE_VALL are returned for pow(), powf(), and
111 powl(), respectively.
112
113
114 For exceptional cases, matherr(3M) tabulates the values to be returned
115 by pow() as specified by SVID3 and XPG3.
116
118 These functions will fail if:
119
120 Domain Error The value of x is negative and y is a finite non-inte‐
121 ger.
122
123 If the integer expression (math_errhandling &
124 MATH_ERREXCEPT) is non-zero, the invalid floating-point
125 exception is raised.
126
127 The pow() function sets errno to EDOM if the value of x
128 is negative and y is non-integral.
129
130
131 Pole Error The value of x is 0 and y is negative.
132
133 If the integer expression (math_errhandling &
134 MATH_ERREXCEPT) is non-zero, the divide-by-zero float‐
135 ing-point exception is raised.
136
137
138 Range Error The result overflows.
139
140 If the integer expression (math_errhandling &
141 MATH_ERREXCEPT) is non-zero, the overflow floating-
142 point exception is raised.
143
144 The pow() function sets errno to EDOM if the value to
145 be returned would cause overflow.
146
147
149 An application wanting to check for exceptions should call feclearex‐
150 cept(FE_ALL_EXCEPT) before calling these functions. On return, if
151 fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is
152 non-zero, an exception has been raised. An application should either
153 examine the return value or check the floating point exception flags to
154 detect exceptions.
155
156
157 An application can also set errno to 0 before calling pow(). On return,
158 if errno is non-zero, an error has occurred. The powf() and powl()
159 functions do not set errno.
160
162 See attributes(5) for descriptions of the following attributes:
163
164
165
166
167 ┌─────────────────────────────┬─────────────────────────────┐
168 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
169 ├─────────────────────────────┼─────────────────────────────┤
170 │Interface Stability │Standard │
171 ├─────────────────────────────┼─────────────────────────────┤
172 │MT-Level │MT-Safe │
173 └─────────────────────────────┴─────────────────────────────┘
174
176 exp(3M), feclearexcept(3M), fetestexcept(3M), isnan(3M), math.h(3HEAD),
177 matherr(3M), attributes(5), standards(5)
178
180 Prior to Solaris 2.6, there was a conflict between the pow() function
181 in this library and the pow() function in the libmp library. This con‐
182 flict was resolved by prepending mp_ to all functions in the libmp
183 library. See mp(3MP) for more information.
184
185
186
187SunOS 5.11 12 Jul 2006 pow(3M)