1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3 .\" <mtk.manpages@gmail.com>
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .\" References consulted:
8 .\" Linux libc source code
9 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
11 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
12 .\" Modified 1995-08-14 by Arnt Gulbrandsen <agulbra@troll.no>
13 .\" Modified 2002-07-27 by Walter Harms
14 .\" (walter.harms@informatik.uni-oldenburg.de)
15 .TH POW 3 2021-03-22 "Linux man-pages (unreleased)"
17 pow, powf, powl \- power functions
20 .RI ( libm ", " \-lm )
25 .BI "double pow(double " x ", double " y );
26 .BI "float powf(float " x ", float " y );
27 .BI "long double powl(long double " x ", long double " y );
31 Feature Test Macro Requirements for glibc (see
32 .BR feature_test_macros (7)):
38 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
39 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
40 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
43 These functions return the value of
49 On success, these functions return the value of
54 If the result overflows,
56 .\" The range error is generated at least as far back as glibc 2.4
57 and the functions return
62 respectively, with the mathematically correct sign.
64 If result underflows, and is not representable,
66 and 0.0 with the appropriate sign is returned.
67 .\" POSIX.1 does not specify the sign of the zero,
68 .\" but http://sources.redhat.com/bugzilla/show_bug.cgi?id=2678
69 .\" points out that the zero has the wrong sign in some cases.
71 .\" pow(\(+-0, <0 [[odd]]) = HUGE_VAL*
77 is an odd integer less than 0,
78 a pole error occurs and
87 .\" pow(\(+-0, <0 [[!odd]]) = HUGE_VAL*
93 is less than 0 and not an odd integer,
94 a pole error occurs and
95 .\" The pole error is generated at least as far back as glibc 2.4
102 .\" pow(\(+-0, >0 [[odd]]) = \(+-0
108 is an odd integer greater than 0,
109 the result is +0 (\-0).
111 .\" pow(\(+-0, >0 [[!odd]]) = +0
117 greater than 0 and not an odd integer,
120 .\" pow(-1, \(+-INFINITY) = 1.0
126 is positive infinity or negative infinity,
132 is +1, the result is 1.0 (even if
136 .\" pow(x, \(+-0) = 1.0
139 is 0, the result is 1.0 (even if
146 is a finite value less than 0, and
148 is a finite noninteger, a domain error occurs,
149 .\" The domain error is generated at least as far back as glibc 2.4
150 and a NaN is returned.
152 .\" pow(|x|<1, -INFINITY) = INFINITY
153 If the absolute value of
158 is negative infinity,
159 the result is positive infinity.
161 .\" pow(|x|>1, -INFINITY) = +0
162 If the absolute value of
167 is negative infinity,
170 .\" pow(|x|<1, INFINITY) = +0
171 If the absolute value of
176 is positive infinity,
179 .\" pow(|x|>1, INFINITY) = INFINITY
180 If the absolute value of
185 is positive infinity,
186 the result is positive infinity.
188 .\" pow(-INFINITY, <0 [[odd]]) = -0
191 is negative infinity,
194 is an odd integer less than 0,
197 .\" pow(-INFINITY, <0 [[!odd]]) = +0
200 is negative infinity,
203 less than 0 and not an odd integer,
206 .\" pow(-INFINITY, >0 [[odd]]) = -INFINITY
209 is negative infinity,
212 is an odd integer greater than 0,
213 the result is negative infinity.
215 .\" pow(-INFINITY, >0 [[!odd]]) = INFINITY
218 is negative infinity,
221 greater than 0 and not an odd integer,
222 the result is positive infinity.
224 .\" pow(INFINITY, <0) = +0
227 is positive infinity,
233 .\" pow(INFINITY, >0) = INFINITY
236 is positive infinity,
240 the result is positive infinity.
242 .\" pow(NaN, y) or pow(x, NaN) = NaN
243 Except as specified above, if
247 is a NaN, the result is a NaN.
249 .\" FIXME . review status of this error
250 .\" longstanding bug report for glibc:
251 .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=369
252 .\" For negative x, and -large and +large y, glibc 2.8 gives incorrect
254 .\" pow(-0.5,-DBL_MAX)=nan
255 .\" EDOM FE_INVALID nan; fail-errno fail-except fail-result;
256 .\" FAIL (expected: range-error-overflow (ERANGE, FE_OVERFLOW); +INF)
258 .\" pow(-1.5,-DBL_MAX)=nan
259 .\" EDOM FE_INVALID nan; fail-errno fail-except fail-result;
260 .\" FAIL (expected: range-error-underflow (ERANGE, FE_UNDERFLOW); +0)
262 .\" pow(-0.5,DBL_MAX)=nan
263 .\" EDOM FE_INVALID nan; fail-errno fail-except fail-result;
264 .\" FAIL (expected: range-error-underflow (ERANGE, FE_UNDERFLOW); +0)
266 .\" pow(-1.5,DBL_MAX)=nan
267 .\" EDOM FE_INVALID nan; fail-errno fail-except fail-result;
268 .\" FAIL (expected: range-error-overflow (ERANGE, FE_OVERFLOW); +INF)
271 for information on how to determine whether an error has occurred
272 when calling these functions.
274 The following errors can occur:
276 Domain error: \fIx\fP is negative, and \fIy\fP is a finite noninteger
280 An invalid floating-point exception
284 Pole error: \fIx\fP is zero, and \fIy\fP is negative
289 A divide-by-zero floating-point exception
293 Range error: the result overflows
297 An overflow floating-point exception
301 Range error: the result underflows
305 An underflow floating-point exception
309 For an explanation of the terms used in this section, see
317 Interface Attribute Value
322 T} Thread safety MT-Safe
328 C99, POSIX.1-2001, POSIX.1-2008.
330 The variant returning
335 .SS Historical bugs (now fixed)
337 .\" https://sourceware.org/bugzilla/show_bug.cgi?id=13932
338 on some architectures (e.g., x86-64)
340 may be more than 10,000 times slower for some inputs
341 than for other nearby inputs.
348 This problem was fixed
349 .\" commit c3d466cba1692708a19c6ff829d0386c83a0c6e5
353 .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=3866
354 in the glibc implementation of
356 were fixed in glibc version 2.16.
358 In glibc 2.9 and earlier,
360 .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6776
361 when a pole error occurs,
365 instead of the POSIX-mandated
368 .\" or possibly 2.9, I haven't found the source code change
369 .\" and I don't have a 2.9 system to test
370 glibc does the right thing.
372 In version 2.3.2 and earlier,
373 .\" Actually, 2.3.2 is the earliest test result I have; so yet
374 .\" to confirm if this error occurs only in 2.3.2.
375 when an overflow or underflow error occurs, glibc's
377 generates a bogus invalid floating-point exception
379 in addition to the overflow or underflow exception.