2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
4 .\" <mtk.manpages@gmail.com>
6 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
8 .\" References consulted:
9 .\" Linux libc source code
10 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
12 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
13 .\" Modified 1995-08-14 by Arnt Gulbrandsen <agulbra@troll.no>
14 .\" Modified 2002-07-27 by Walter Harms
15 .\" (walter.harms@informatik.uni-oldenburg.de)
16 .TH pow 3 (date) "Linux man-pages (unreleased)"
18 pow, powf, powl \- power functions
21 .RI ( libm ", " \-lm )
26 .BI "double pow(double " x ", double " y );
27 .BI "float powf(float " x ", float " y );
28 .BI "long double powl(long double " x ", long double " y );
32 Feature Test Macro Requirements for glibc (see
33 .BR feature_test_macros (7)):
39 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
40 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
41 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
44 These functions return the value of
50 On success, these functions return the value of
55 If the result overflows,
57 .\" The range error is generated at least as far back as glibc 2.4
58 and the functions return
63 respectively, with the mathematically correct sign.
65 If result underflows, and is not representable,
67 and 0.0 with the appropriate sign is returned.
68 .\" POSIX.1 does not specify the sign of the zero,
69 .\" but https://www.sourceware.org/bugzilla/show_bug.cgi?id=2678
70 .\" points out that the zero has the wrong sign in some cases.
72 .\" pow(\(+-0, <0 [[odd]]) = HUGE_VAL*
78 is an odd integer less than 0,
79 a pole error occurs and
88 .\" pow(\(+-0, <0 [[!odd]]) = HUGE_VAL*
94 is less than 0 and not an odd integer,
95 a pole error occurs and
96 .\" The pole error is generated at least as far back as glibc 2.4
103 .\" pow(\(+-0, >0 [[odd]]) = \(+-0
109 is an odd integer greater than 0,
110 the result is +0 (\-0).
112 .\" pow(\(+-0, >0 [[!odd]]) = +0
118 greater than 0 and not an odd integer,
121 .\" pow(-1, \(+-INFINITY) = 1.0
127 is positive infinity or negative infinity,
133 is +1, the result is 1.0 (even if
137 .\" pow(x, \(+-0) = 1.0
140 is 0, the result is 1.0 (even if
147 is a finite value less than 0, and
149 is a finite noninteger, a domain error occurs,
150 .\" The domain error is generated at least as far back as glibc 2.4
151 and a NaN is returned.
153 .\" pow(|x|<1, -INFINITY) = INFINITY
154 If the absolute value of
159 is negative infinity,
160 the result is positive infinity.
162 .\" pow(|x|>1, -INFINITY) = +0
163 If the absolute value of
168 is negative infinity,
171 .\" pow(|x|<1, INFINITY) = +0
172 If the absolute value of
177 is positive infinity,
180 .\" pow(|x|>1, INFINITY) = INFINITY
181 If the absolute value of
186 is positive infinity,
187 the result is positive infinity.
189 .\" pow(-INFINITY, <0 [[odd]]) = -0
192 is negative infinity,
195 is an odd integer less than 0,
198 .\" pow(-INFINITY, <0 [[!odd]]) = +0
201 is negative infinity,
204 less than 0 and not an odd integer,
207 .\" pow(-INFINITY, >0 [[odd]]) = -INFINITY
210 is negative infinity,
213 is an odd integer greater than 0,
214 the result is negative infinity.
216 .\" pow(-INFINITY, >0 [[!odd]]) = INFINITY
219 is negative infinity,
222 greater than 0 and not an odd integer,
223 the result is positive infinity.
225 .\" pow(INFINITY, <0) = +0
228 is positive infinity,
234 .\" pow(INFINITY, >0) = INFINITY
237 is positive infinity,
241 the result is positive infinity.
243 .\" pow(NaN, y) or pow(x, NaN) = NaN
244 Except as specified above, if
248 is a NaN, the result is a NaN.
250 .\" FIXME . review status of this error
251 .\" longstanding bug report for glibc:
252 .\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=369
253 .\" For negative x, and -large and +large y, glibc 2.8 gives incorrect
255 .\" pow(-0.5,-DBL_MAX)=nan
256 .\" EDOM FE_INVALID nan; fail-errno fail-except fail-result;
257 .\" FAIL (expected: range-error-overflow (ERANGE, FE_OVERFLOW); +INF)
259 .\" pow(-1.5,-DBL_MAX)=nan
260 .\" EDOM FE_INVALID nan; fail-errno fail-except fail-result;
261 .\" FAIL (expected: range-error-underflow (ERANGE, FE_UNDERFLOW); +0)
263 .\" pow(-0.5,DBL_MAX)=nan
264 .\" EDOM FE_INVALID nan; fail-errno fail-except fail-result;
265 .\" FAIL (expected: range-error-underflow (ERANGE, FE_UNDERFLOW); +0)
267 .\" pow(-1.5,DBL_MAX)=nan
268 .\" EDOM FE_INVALID nan; fail-errno fail-except fail-result;
269 .\" FAIL (expected: range-error-overflow (ERANGE, FE_OVERFLOW); +INF)
272 for information on how to determine whether an error has occurred
273 when calling these functions.
275 The following errors can occur:
277 Domain error: \fIx\fP is negative, and \fIy\fP is a finite noninteger
281 An invalid floating-point exception
285 Pole error: \fIx\fP is zero, and \fIy\fP is negative
290 A divide-by-zero floating-point exception
294 Range error: the result overflows
298 An overflow floating-point exception
302 Range error: the result underflows
306 An underflow floating-point exception
310 For an explanation of the terms used in this section, see
318 Interface Attribute Value
323 T} Thread safety MT-Safe
333 The variant returning
338 .SS Historical bugs (now fixed)
340 .\" https://sourceware.org/bugzilla/show_bug.cgi?id=13932
341 on some architectures (e.g., x86-64)
343 may be more than 10,000 times slower for some inputs
344 than for other nearby inputs.
351 This problem was fixed
352 .\" commit c3d466cba1692708a19c6ff829d0386c83a0c6e5
356 .\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=3866
357 in the glibc implementation of
359 were fixed in glibc 2.16.
361 In glibc 2.9 and earlier,
363 .\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=6776
364 when a pole error occurs,
368 instead of the POSIX-mandated
371 .\" or possibly 2.9, I haven't found the source code change
372 .\" and I don't have a 2.9 system to test
373 glibc does the right thing.
375 In glibc 2.3.2 and earlier,
376 .\" Actually, glibc 2.3.2 is the earliest test result I have; so yet
377 .\" to confirm if this error occurs only in glibc 2.3.2.
378 when an overflow or underflow error occurs, glibc's
380 generates a bogus invalid floating-point exception
382 in addition to the overflow or underflow exception.